@hollis-labs/surface-page 0.3.0 → 0.4.1

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 (40) hide show
  1. package/dist/chunks/chunk-LODRWYOW.js +2060 -0
  2. package/dist/gallery.js +491 -310
  3. package/dist/index.js +385 -387
  4. package/dist/registry-items.json +3 -0
  5. package/dist/sdk.js +13 -1
  6. package/dist/types/agent/api.d.ts +34 -2
  7. package/dist/types/agent/session.d.ts +2 -5
  8. package/dist/types/cards/store.d.ts +13 -1
  9. package/dist/types/cards/views.d.ts +3 -2
  10. package/dist/types/cite/core/detect.d.ts +26 -0
  11. package/dist/types/cite/core/index.d.ts +17 -0
  12. package/dist/types/cite/core/kinds/caster.d.ts +3 -0
  13. package/dist/types/cite/core/kinds/fragment.d.ts +3 -0
  14. package/dist/types/cite/core/kinds/ops.d.ts +3 -0
  15. package/dist/types/cite/core/kinds/path.d.ts +8 -0
  16. package/dist/types/cite/core/kinds/registry.d.ts +3 -0
  17. package/dist/types/cite/core/kinds/tesseract.d.ts +11 -0
  18. package/dist/types/cite/core/kinds/tether.d.ts +4 -0
  19. package/dist/types/cite/core/kinds/torque.d.ts +11 -0
  20. package/dist/types/cite/core/kinds/url.d.ts +2 -0
  21. package/dist/types/cite/core/kinds/work.d.ts +3 -0
  22. package/dist/types/cite/core/preview.d.ts +8 -0
  23. package/dist/types/cite/core/registry.d.ts +19 -0
  24. package/dist/types/cite/core/resolver.d.ts +34 -0
  25. package/dist/types/cite/core/scan-utils.d.ts +9 -0
  26. package/dist/types/cite/core/tach.d.ts +3 -0
  27. package/dist/types/cite/core/types.d.ts +161 -0
  28. package/dist/types/cite/record.d.ts +11 -0
  29. package/dist/types/cite/remark.d.ts +32 -0
  30. package/dist/types/cite/store.d.ts +35 -0
  31. package/dist/types/cite/structured-view.d.ts +9 -0
  32. package/dist/types/cite/structured.d.ts +90 -0
  33. package/dist/types/cite/terminal.d.ts +15 -0
  34. package/dist/types/cite/ui.d.ts +52 -0
  35. package/dist/types/gallery/Gallery.d.ts +5 -0
  36. package/dist/types/gallery/cite.d.ts +1 -0
  37. package/dist/types/sdk/index.d.ts +3 -0
  38. package/dist/types/sdk/types.d.ts +37 -0
  39. package/package.json +5 -5
  40. package/dist/chunks/chunk-ZT6LTRMY.js +0 -220
package/dist/index.js CHANGED
@@ -1,174 +1,47 @@
1
1
  import {
2
2
  ApiError,
3
+ CiteFloat,
4
+ CiteRecordView,
3
5
  Icon,
6
+ act,
4
7
  allSettings,
5
8
  anchorElement,
9
+ app,
6
10
  call,
11
+ citeMarkdownExtensions,
12
+ closeWindow,
7
13
  connect,
14
+ deleteLayout,
15
+ desk,
16
+ deskState,
8
17
  getSetting,
18
+ initCite,
9
19
  isConnected,
20
+ listLayouts,
21
+ loadLayout,
22
+ loadManifest,
10
23
  loadSettings,
24
+ notYetKept,
11
25
  onConnection,
12
26
  onEvent,
13
27
  replyMark,
14
28
  resolveMark,
29
+ runCommand,
30
+ saveLayout,
31
+ setClientRunner,
32
+ setConfirm,
15
33
  setSetting,
34
+ toWin,
35
+ useDeskState,
16
36
  useEvent,
17
- useSetting
18
- } from "./chunks/chunk-ZT6LTRMY.js";
37
+ useSetting,
38
+ viewById
39
+ } from "./chunks/chunk-LODRWYOW.js";
19
40
 
20
41
  // ../../web/src/boot.tsx
21
42
  import { StrictMode, useEffect as useEffect13, useState as useState11 } from "react";
22
43
  import { createRoot } from "react-dom/client";
23
-
24
- // ../../web/src/cards/views.tsx
25
- import { useCallback, useEffect as useEffect2, useState } from "react";
26
- import { Button } from "@/components/ui/button";
27
- import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
28
- import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
29
-
30
- // ../../web/src/desk/store.ts
31
- import { useSyncExternalStore } from "react";
32
- var notYetKept = (w) => !!w.opened_by && w.opened_by !== "owner" && !w.kept;
33
- var manifest = null;
34
- var state = { wins: [], focus: "", tree: { root: { type: "row" } }, layout: "tile", ratio: 0.56, rev: -1 };
35
- var subs = /* @__PURE__ */ new Set();
36
- var emit = () => {
37
- for (const fn of subs) fn();
38
- };
39
- onEvent("desk.changed", (ev) => {
40
- const next = ev.data;
41
- if (next && next.rev >= state.rev) {
42
- state = next;
43
- emit();
44
- }
45
- });
46
- async function loadManifest() {
47
- manifest = await call("GET", "/api/app");
48
- return manifest;
49
- }
50
- var app = () => {
51
- if (!manifest) throw new Error("the app manifest is not loaded yet");
52
- return manifest;
53
- };
54
- var viewById = (id) => manifest?.views.find((v) => v.id === id);
55
- function viewForFile(name) {
56
- const base2 = name.toLowerCase().split("/").pop() ?? "";
57
- const matches2 = (pattern) => {
58
- const p = pattern.toLowerCase();
59
- if (p.startsWith("*")) return base2.endsWith(p.slice(1));
60
- return base2 === p;
61
- };
62
- return manifest?.views.find((v) => v.opens?.some(matches2));
63
- }
64
- var deskState = () => state;
65
- var subscribe = (fn) => {
66
- subs.add(fn);
67
- return () => {
68
- subs.delete(fn);
69
- };
70
- };
71
- function useDeskState() {
72
- return useSyncExternalStore(subscribe, deskState);
73
- }
74
- async function act(action) {
75
- const res = await call("POST", "/api/desk/actions", action);
76
- return res.window;
77
- }
78
- var toWin = (w, focus) => ({
79
- id: w.id,
80
- view: w.view,
81
- module: w.module,
82
- title: w.title,
83
- key: w.key,
84
- args: w.args ?? {},
85
- state: w.state,
86
- focused: w.id === focus
87
- });
88
- var pendingReports = /* @__PURE__ */ new Map();
89
- var reportTimer;
90
- function flushReports() {
91
- reportTimer = void 0;
92
- for (const [id, st] of pendingReports) {
93
- void act({ type: "state", id, state: st }).catch(() => {
94
- });
95
- }
96
- pendingReports.clear();
97
- }
98
- var confirmImpl = async (q) => window.confirm(q.title);
99
- var setConfirm = (fn) => {
100
- confirmImpl = fn;
101
- };
102
- var clientRunner = () => void 0;
103
- var setClientRunner = (fn) => {
104
- clientRunner = fn;
105
- };
106
- async function runCommand(id, args) {
107
- const local = clientRunner(id, args);
108
- if (local !== void 0) return await local;
109
- const res = await call("POST", `/api/commands/${encodeURIComponent(id)}`, { args: args ?? {} });
110
- return res.result;
111
- }
112
- async function closeWindow(id) {
113
- const w = state.wins.find((x) => x.id === id);
114
- if (w?.dirty && getSetting("surface.confirm_close_dirty") === false) {
115
- await act({ type: "close", id, force: true });
116
- return;
117
- }
118
- if (w?.dirty) {
119
- const yes = await confirmImpl({
120
- title: `Close \u201C${w.title}\u201D?`,
121
- message: "It holds unsaved work.",
122
- confirmLabel: "Close anyway",
123
- danger: true
124
- });
125
- if (!yes) return;
126
- await act({ type: "close", id, force: true });
127
- return;
128
- }
129
- await act({ type: "close", id });
130
- }
131
- function unlessGone(err) {
132
- if (err instanceof ApiError && /no window/.test(err.message)) return void 0;
133
- throw err;
134
- }
135
- var desk = {
136
- async open(view, opts) {
137
- const w = await act({ type: "open", view, ...opts });
138
- if (!w) throw new Error(`could not open ${view}`);
139
- return toWin(w, w.id);
140
- },
141
- async openFile(name, opts) {
142
- const view = viewForFile(name);
143
- return view ? desk.open(view.id, opts) : null;
144
- },
145
- close: closeWindow,
146
- async focus(id) {
147
- await act({ type: "focus", id }).catch(unlessGone);
148
- },
149
- async setTitle(id, title) {
150
- await act({ type: "title", id, title }).catch(unlessGone);
151
- },
152
- async setArgs(id, args) {
153
- await act({ type: "args", id, args }).catch(unlessGone);
154
- },
155
- report(id, st) {
156
- pendingReports.set(id, st);
157
- if (reportTimer === void 0) reportTimer = window.setTimeout(flushReports, 250);
158
- },
159
- setDirty(id, dirty) {
160
- const w = state.wins.find((x) => x.id === id);
161
- if (w && !!w.dirty !== dirty) void act({ type: "dirty", id, dirty }).catch(() => {
162
- });
163
- },
164
- run: runCommand,
165
- confirm: (q) => confirmImpl(q),
166
- windows: () => state.wins.map((w) => toWin(w, state.focus))
167
- };
168
- var listLayouts = () => call("GET", "/api/layouts");
169
- var saveLayout = (name, about) => call("POST", "/api/layouts", { name, about });
170
- var loadLayout = (name) => call("POST", `/api/layouts/${encodeURIComponent(name)}/load`);
171
- var deleteLayout = (name) => call("DELETE", `/api/layouts/${encodeURIComponent(name)}`);
44
+ import { MarkdownExtensions } from "@/components/ui/markdown";
172
45
 
173
46
  // ../../web/src/cards/renderers.tsx
174
47
  import {
@@ -178,6 +51,7 @@ import {
178
51
  validateForm
179
52
  } from "@hollis-labs/surface-cards";
180
53
  import { Component, useMemo as useMemo2 } from "react";
54
+ import { Button } from "@/components/ui/button";
181
55
  import { CardApproval } from "@/components/ui/card-approval";
182
56
  import { CardChoice } from "@/components/ui/card-choice";
183
57
  import { CardConfirm } from "@/components/ui/card-confirm";
@@ -194,7 +68,7 @@ import {
194
68
  GenuiController,
195
69
  parseRecovery
196
70
  } from "@hollis-labs/surface-genui";
197
- import { useEffect, useMemo, useSyncExternalStore as useSyncExternalStore2 } from "react";
71
+ import { useEffect, useMemo, useSyncExternalStore } from "react";
198
72
  import { GenuiSurface } from "@/components/ui/genui-surface";
199
73
  import { jsx } from "react/jsx-runtime";
200
74
  async function send(method, path, body, signal) {
@@ -261,7 +135,7 @@ function GenuiCard({ card }) {
261
135
  const raw = useMemo(() => JSON.stringify(card.payload?.envelope ?? null), [card.payload]);
262
136
  const controller = useMemo(() => new GenuiController(raw, transport), [raw]);
263
137
  useEffect(() => () => controller.dispose(), [controller]);
264
- const snap = useSyncExternalStore2(controller.subscribe, controller.getSnapshot);
138
+ const snap = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
265
139
  const envelope = snap.envelope;
266
140
  const root = envelope.data.createSurface.components[0];
267
141
  const closed = !!card.status;
@@ -299,9 +173,28 @@ function GenuiCard({ card }) {
299
173
 
300
174
  // ../../web/src/cards/store.ts
301
175
  import {
302
- createCardEngine
176
+ acceptsLateAnswer,
177
+ createCardEngine,
178
+ createDraftStore
303
179
  } from "@hollis-labs/surface-cards";
304
- import { useSyncExternalStore as useSyncExternalStore3 } from "react";
180
+ import { useSyncExternalStore as useSyncExternalStore2 } from "react";
181
+ var LATE_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
182
+ function lateOpen(c) {
183
+ if (!acceptsLateAnswer(c)) return false;
184
+ const at = c.responded ? Date.parse(c.responded) : Number.NaN;
185
+ return !Number.isFinite(at) || Date.now() - at < LATE_WINDOW_MS;
186
+ }
187
+ var isLive = (c) => !c.status || lateOpen(c);
188
+ var drafts = createDraftStore(typeof localStorage === "undefined" ? void 0 : localStorage);
189
+ var loadDraft = (id) => drafts.load(id);
190
+ function saveDraft(id, draft) {
191
+ const c = cards.get(id);
192
+ if (c && !isLive(c)) return;
193
+ drafts.save(id, draft);
194
+ }
195
+ var lateShown = /* @__PURE__ */ new Map();
196
+ var LATE_SHOWN_MS = 15e3;
197
+ var recentlyAnsweredLate = (c) => c.late === true && c.status === "submitted" && Date.now() - (lateShown.get(c.id) ?? 0) < LATE_SHOWN_MS;
305
198
  var ANSWERABLE = ["confirm", "prompt", "choice", "form", "approval"];
306
199
  var answer = [{ id: "answer", label: "Answer" }];
307
200
  var rules = [
@@ -314,13 +207,13 @@ var rules = [
314
207
  var engine = createCardEngine({ rules, now: () => Date.now() });
315
208
  var cards = /* @__PURE__ */ new Map();
316
209
  var stale = /* @__PURE__ */ new Set();
317
- var subs2 = /* @__PURE__ */ new Set();
210
+ var subs = /* @__PURE__ */ new Set();
318
211
  var version = 0;
319
- var emit2 = () => {
212
+ var emit = () => {
320
213
  version++;
321
- for (const fn of subs2) fn();
214
+ for (const fn of subs) fn();
322
215
  };
323
- engine.subscribe(emit2);
216
+ engine.subscribe(emit);
324
217
  function take(c) {
325
218
  const have = cards.get(c.id);
326
219
  if (have && (have.revision ?? 0) > (c.revision ?? 0)) return;
@@ -337,19 +230,29 @@ function take(c) {
337
230
  expiresAt: Number.isFinite(expiresAt) ? expiresAt : void 0
338
231
  });
339
232
  if (c.status) engine.applyServerState(c.id, c.status, { supersededBy: c.superseded_by });
340
- emit2();
233
+ if (!isLive(c)) drafts.clear(c.id);
234
+ emit();
341
235
  }
342
236
  var started = false;
343
237
  function startCards() {
344
238
  if (started) return;
345
239
  started = true;
346
240
  onEvent("cards.changed", (ev) => take(ev.data));
347
- void call("GET", "/api/cards").then((open) => open.forEach(take)).catch(() => {
241
+ void call("GET", "/api/cards?late=1").then((live) => {
242
+ live.forEach(take);
243
+ const ids = new Set(live.map((c) => c.id));
244
+ drafts.prune((id) => ids.has(id));
245
+ }).catch(() => {
348
246
  });
349
247
  window.setInterval(() => engine.dismissExpiredToasts(), 2e3);
350
248
  }
351
249
  async function respond(id, outcome) {
352
250
  try {
251
+ const was = cards.get(id);
252
+ if (was && lateOpen(was) && outcome.status === "submitted") {
253
+ lateShown.set(id, Date.now());
254
+ window.setTimeout(emit, LATE_SHOWN_MS + 100);
255
+ }
353
256
  take(await call("POST", `/api/cards/${encodeURIComponent(id)}/response`, outcome));
354
257
  } catch (err) {
355
258
  if (err instanceof ApiError && err.status === 409) {
@@ -357,7 +260,7 @@ async function respond(id, outcome) {
357
260
  if (now) take(now);
358
261
  else {
359
262
  stale.add(id);
360
- emit2();
263
+ emit();
361
264
  }
362
265
  return;
363
266
  }
@@ -366,10 +269,10 @@ async function respond(id, outcome) {
366
269
  }
367
270
  var dismissToast = (id) => engine.dismissToast(id);
368
271
  var isStale = (id) => stale.has(id);
369
- var subscribe2 = (fn) => {
370
- subs2.add(fn);
272
+ var subscribe = (fn) => {
273
+ subs.add(fn);
371
274
  return () => {
372
- subs2.delete(fn);
275
+ subs.delete(fn);
373
276
  };
374
277
  };
375
278
  var cache = /* @__PURE__ */ new Map();
@@ -384,14 +287,14 @@ function shown(surface) {
384
287
  return list2;
385
288
  }
386
289
  function useCards(surface) {
387
- return useSyncExternalStore3(subscribe2, () => shown(surface));
290
+ return useSyncExternalStore2(subscribe, () => shown(surface));
388
291
  }
389
292
  function useCard(id) {
390
- return useSyncExternalStore3(subscribe2, () => cards.get(id));
293
+ return useSyncExternalStore2(subscribe, () => cards.get(id));
391
294
  }
392
295
 
393
296
  // ../../web/src/cards/renderers.tsx
394
- import { jsx as jsx2 } from "react/jsx-runtime";
297
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
395
298
  var registry = createCardRegistry();
396
299
  var registerCard = (kind, version3, component) => registry.register(kind, version3, component);
397
300
  var str = (v) => typeof v === "string" && v !== "" ? v : void 0;
@@ -415,16 +318,24 @@ function describeOutcome(card) {
415
318
  return void 0;
416
319
  }
417
320
  var clock = new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit" });
321
+ function receiptOf(card) {
322
+ const said = describeOutcome(card);
323
+ if (!card.late || card.status !== "submitted") return said;
324
+ const sent = card.delivered ? "Sent to the agent" : "Sending to the agent";
325
+ return said ? `${sent} \xB7 ${said}` : sent;
326
+ }
418
327
  function answerable({ card, respond: send2 }) {
419
- const state3 = classifyPriorResponse(card.status);
328
+ const late = lateOpen(card);
329
+ const state2 = late ? "open" : classifyPriorResponse(card.status).kind;
420
330
  const at = card.expires_at ? Date.parse(card.expires_at) : Number.NaN;
421
331
  return {
422
332
  title: card.title,
423
- state: state3.kind,
333
+ state: state2,
424
334
  stale: isStale(card.id),
425
- receipt: describeOutcome(card),
426
- expires: state3.kind === "open" && Number.isFinite(at) ? `at ${clock.format(at)}` : void 0,
427
- onRespond: send2
335
+ receipt: receiptOf(card),
336
+ expires: !late && state2 === "open" && Number.isFinite(at) ? `at ${clock.format(at)}` : void 0,
337
+ onRespond: send2,
338
+ ...isLive(card) ? { draft: loadDraft(card.id), onDraft: (d) => saveDraft(card.id, d) } : {}
428
339
  };
429
340
  }
430
341
  registerCard("info", "1", ({ card, respond: send2 }) => /* @__PURE__ */ jsx2(
@@ -503,7 +414,8 @@ registerCard("approval", "1", (p) => /* @__PURE__ */ jsx2(
503
414
  risk: p.card.risk || "low",
504
415
  changes: list(p.card.payload?.changes),
505
416
  requestedBy: str(p.card.payload?.requested_by),
506
- phrase: str(p.card.payload?.phrase)
417
+ phrase: str(p.card.payload?.phrase),
418
+ perChange: p.card.payload?.per_change === true
507
419
  }
508
420
  ));
509
421
  registerCard("progress", "1", ({ card }) => /* @__PURE__ */ jsx2(
@@ -557,15 +469,36 @@ function CardView({ card }) {
557
469
  );
558
470
  }
559
471
  const Draw = found.component;
560
- return /* @__PURE__ */ jsx2(Boundary, { card, children: /* @__PURE__ */ jsx2(Draw, { card, respond: (outcome) => respond(card.id, outcome) }) }, `${card.kind}@${card.version ?? "1"}`);
472
+ const drawn = /* @__PURE__ */ jsx2(Boundary, { card, children: /* @__PURE__ */ jsx2(Draw, { card, respond: (outcome) => respond(card.id, outcome) }) }, `${card.kind}@${card.version ?? "1"}`);
473
+ if (!lateOpen(card)) return drawn;
474
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "card-late", className: "flex flex-col gap-1.5", children: [
475
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
476
+ /* @__PURE__ */ jsx2("p", { className: "text-muted-foreground text-xs", children: "The agent stopped waiting for this (its run ended). Answer anyway and it is sent to the agent as a message." }),
477
+ /* @__PURE__ */ jsx2(
478
+ Button,
479
+ {
480
+ variant: "ghost",
481
+ size: "xs",
482
+ className: "shrink-0",
483
+ onClick: () => void respond(card.id, { status: "canceled" }),
484
+ children: "Dismiss"
485
+ }
486
+ )
487
+ ] }),
488
+ drawn
489
+ ] });
561
490
  }
562
491
 
563
492
  // ../../web/src/cards/views.tsx
564
- import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
493
+ import { useCallback, useEffect as useEffect2, useState } from "react";
494
+ import { Button as Button2 } from "@/components/ui/button";
495
+ import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
496
+ import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
497
+ import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
565
498
  var isOpen = (c) => !c.status;
566
499
  function CardDock() {
567
500
  useEffect2(startCards, []);
568
- const open = useCards("inline").filter((s) => isOpen(s.card));
501
+ const open = useCards("inline").filter((s) => isLive(s.card) || recentlyAnsweredLate(s.card));
569
502
  if (open.length === 0) return null;
570
503
  return /* @__PURE__ */ jsx3(
571
504
  "div",
@@ -587,16 +520,16 @@ function CardHost() {
587
520
  const blocking = useCards("modal").filter((s) => isOpen(s.card));
588
521
  const [hidden, setHidden] = useState(null);
589
522
  const front = blocking.find((s) => s.card.id !== hidden);
590
- return /* @__PURE__ */ jsxs(Fragment, { children: [
523
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
591
524
  toasts.length > 0 && /* @__PURE__ */ jsx3(
592
525
  "div",
593
526
  {
594
527
  "data-slot": "card-toasts",
595
528
  className: "pointer-events-none fixed bottom-3 left-3 z-40 flex w-[min(24rem,calc(100vw-1.5rem))] flex-col gap-2",
596
- children: toasts.slice(-4).map((s) => /* @__PURE__ */ jsxs("div", { className: "pointer-events-auto relative shadow-lg", children: [
529
+ children: toasts.slice(-4).map((s) => /* @__PURE__ */ jsxs2("div", { className: "pointer-events-auto relative shadow-lg", children: [
597
530
  /* @__PURE__ */ jsx3(CardView, { card: s.card }),
598
531
  s.view.answerable && /* @__PURE__ */ jsx3(
599
- Button,
532
+ Button2,
600
533
  {
601
534
  variant: "ghost",
602
535
  size: "xs",
@@ -609,7 +542,7 @@ function CardHost() {
609
542
  ] }, s.card.id))
610
543
  }
611
544
  ),
612
- /* @__PURE__ */ jsx3(Dialog, { open: !!front, onOpenChange: (open) => !open && front && setHidden(front.card.id), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md gap-0 p-0 ring-0", showCloseButton: false, children: [
545
+ /* @__PURE__ */ jsx3(Dialog, { open: !!front, onOpenChange: (open) => !open && front && setHidden(front.card.id), children: /* @__PURE__ */ jsxs2(DialogContent, { className: "max-w-md gap-0 p-0 ring-0", showCloseButton: false, children: [
613
546
  /* @__PURE__ */ jsx3(DialogTitle, { className: "sr-only", children: front?.card.title ?? "A question" }),
614
547
  /* @__PURE__ */ jsx3(DialogDescription, { className: "sr-only", children: "Something is waiting on your answer." }),
615
548
  front && /* @__PURE__ */ jsx3(CardView, { card: front.card })
@@ -622,11 +555,11 @@ function CardsWindow(_) {
622
555
  const refresh = useCallback(() => void call("GET", "/api/cards?all=1").then(setAll), []);
623
556
  useEffect2(refresh, [refresh]);
624
557
  useEvent("cards.changed", refresh);
625
- const open = all.filter(isOpen);
626
- const closed = all.filter((c) => !isOpen(c)).reverse();
627
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 p-4", children: [
628
- /* @__PURE__ */ jsx3("p", { className: "text-muted-foreground", children: "Cards are what the app puts in front of you outside a window: a question, a request to approve, progress on work. The open ones wait here until they are answered." }),
629
- all.length === 0 && /* @__PURE__ */ jsx3(Empty, { children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
558
+ const open = all.filter(isLive);
559
+ const closed = all.filter((c) => !isLive(c)).reverse();
560
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 p-4", children: [
561
+ /* @__PURE__ */ jsx3("p", { className: "text-muted-foreground", children: "Cards are what the app puts in front of you outside a window: a question, a request to approve, progress on work. The open ones wait here until they are answered, and so does a question the agent stopped waiting for." }),
562
+ all.length === 0 && /* @__PURE__ */ jsx3(Empty, { children: /* @__PURE__ */ jsxs2(EmptyHeader, { children: [
630
563
  /* @__PURE__ */ jsx3(EmptyTitle, { children: "No cards yet" }),
631
564
  /* @__PURE__ */ jsx3(EmptyDescription, { children: "The agent and the app's modules show them as they need you." })
632
565
  ] }) }),
@@ -636,8 +569,8 @@ function CardsWindow(_) {
636
569
  ] });
637
570
  }
638
571
  function Sourced({ card }) {
639
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
640
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-muted-foreground text-xs", children: [
572
+ return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1", children: [
573
+ /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-1.5 text-muted-foreground text-xs", children: [
641
574
  /* @__PURE__ */ jsx3(Icon, { name: card.source === "agent" ? "bot" : "puzzle", size: 12 }),
642
575
  card.source || "app"
643
576
  ] }),
@@ -648,7 +581,7 @@ function Sourced({ card }) {
648
581
  // ../../web/src/desk/coreViews.tsx
649
582
  import { useCallback as useCallback3, useEffect as useEffect4, useState as useState3 } from "react";
650
583
  import { Badge as Badge2 } from "@/components/ui/badge";
651
- import { Button as Button3 } from "@/components/ui/button";
584
+ import { Button as Button4 } from "@/components/ui/button";
652
585
  import { Input } from "@/components/ui/input";
653
586
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
654
587
  import { Switch as Switch2 } from "@/components/ui/switch";
@@ -656,12 +589,12 @@ import { Switch as Switch2 } from "@/components/ui/switch";
656
589
  // ../../web/src/desk/ContextInspector.tsx
657
590
  import { useCallback as useCallback2, useEffect as useEffect3, useState as useState2 } from "react";
658
591
  import { Badge } from "@/components/ui/badge";
659
- import { Button as Button2 } from "@/components/ui/button";
592
+ import { Button as Button3 } from "@/components/ui/button";
660
593
  import { Empty as Empty2, EmptyDescription as EmptyDescription2, EmptyHeader as EmptyHeader2, EmptyTitle as EmptyTitle2 } from "@/components/ui/empty";
661
594
  import { Item, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item";
662
595
  import { Switch } from "@/components/ui/switch";
663
596
  import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
664
- import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
597
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
665
598
  var WHY = {
666
599
  focus: "the window in front belongs to it",
667
600
  kept: "it stayed from before: the window in front has no slot of its own",
@@ -676,7 +609,7 @@ var when = (iso) => {
676
609
  var byOwner = (s) => s.actor === "owner" || s.actor === "" || s.actor === void 0;
677
610
  var correction = (s) => byOwner(s) && (s.kind === "pin" || s.kind === "unpin");
678
611
  function Row({ label, children }) {
679
- return /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[9rem_1fr] gap-3 py-1.5 text-sm", children: [
612
+ return /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-[9rem_1fr] gap-3 py-1.5 text-sm", children: [
680
613
  /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground text-xs", children: label }),
681
614
  /* @__PURE__ */ jsx4("div", { className: "flex min-w-0 flex-wrap items-center gap-1", children })
682
615
  ] });
@@ -684,24 +617,24 @@ function Row({ label, children }) {
684
617
  var chips = (list2, empty = "none") => list2 && list2.length > 0 ? list2.map((x) => /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: x }, x)) : /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground text-xs", children: empty });
685
618
  function TurnDetail({ t }) {
686
619
  const corrections = (t.signals ?? []).filter(correction);
687
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1 p-4", children: [
620
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-1 p-4", children: [
688
621
  /* @__PURE__ */ jsx4("p", { className: "text-sm whitespace-pre-wrap", children: t.text }),
689
- /* @__PURE__ */ jsxs2("span", { className: "mb-2 text-xs text-muted-foreground", children: [
622
+ /* @__PURE__ */ jsxs3("span", { className: "mb-2 text-xs text-muted-foreground", children: [
690
623
  when(t.at),
691
624
  t.run_id ? ` \xB7 run ${t.run_id}` : ""
692
625
  ] }),
693
- /* @__PURE__ */ jsxs2(Row, { label: "In front", children: [
626
+ /* @__PURE__ */ jsxs3(Row, { label: "In front", children: [
694
627
  t.view ? /* @__PURE__ */ jsx4(Badge, { variant: "secondary", children: t.view }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing" }),
695
- t.mode && /* @__PURE__ */ jsxs2(Badge, { variant: "outline", children: [
628
+ t.mode && /* @__PURE__ */ jsxs3(Badge, { variant: "outline", children: [
696
629
  "mode ",
697
630
  t.mode
698
631
  ] }),
699
632
  t.layout && /* @__PURE__ */ jsx4(Badge, { variant: "outline", children: t.layout })
700
633
  ] }),
701
634
  /* @__PURE__ */ jsx4(Row, { label: "Open", children: chips(t.open_views) }),
702
- /* @__PURE__ */ jsxs2(Row, { label: "Slot", children: [
635
+ /* @__PURE__ */ jsxs3(Row, { label: "Slot", children: [
703
636
  /* @__PURE__ */ jsx4(Badge, { children: t.slot || "none" }),
704
- /* @__PURE__ */ jsxs2("span", { className: "text-xs text-muted-foreground", children: [
637
+ /* @__PURE__ */ jsxs3("span", { className: "text-xs text-muted-foreground", children: [
705
638
  "because ",
706
639
  WHY[t.why ?? ""] ?? t.why ?? "?"
707
640
  ] })
@@ -709,23 +642,23 @@ function TurnDetail({ t }) {
709
642
  /* @__PURE__ */ jsx4(Row, { label: "Slots offered", children: chips(t.slots) }),
710
643
  /* @__PURE__ */ jsx4(Row, { label: "Tools to mind", children: chips(t.top_of_mind) }),
711
644
  /* @__PURE__ */ jsx4(Row, { label: "Routed", children: t.routed ? /* @__PURE__ */ jsx4(Badge, { variant: "outline", children: t.routed }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "no rule" }) }),
712
- /* @__PURE__ */ jsxs2(Row, { label: "Reflexes", children: [
645
+ /* @__PURE__ */ jsxs3(Row, { label: "Reflexes", children: [
713
646
  chips(t.fired),
714
647
  t.halted && /* @__PURE__ */ jsx4(Badge, { variant: "destructive", children: "halted the turn" })
715
648
  ] }),
716
- /* @__PURE__ */ jsx4(Row, { label: "Context size", children: /* @__PURE__ */ jsxs2("span", { className: "font-mono text-xs", children: [
649
+ /* @__PURE__ */ jsx4(Row, { label: "Context size", children: /* @__PURE__ */ jsxs3("span", { className: "font-mono text-xs", children: [
717
650
  t.block_chars.toLocaleString(),
718
651
  " characters"
719
652
  ] }) }),
720
653
  /* @__PURE__ */ jsx4(Row, { label: "Budget cut", children: chips(t.trimmed, "nothing cut") }),
721
- /* @__PURE__ */ jsx4(Row, { label: "What followed", children: (t.signals ?? []).length === 0 ? /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing in the next 15 minutes" }) : /* @__PURE__ */ jsx4("ul", { className: "flex w-full flex-col gap-1", children: (t.signals ?? []).map((s) => /* @__PURE__ */ jsxs2(
654
+ /* @__PURE__ */ jsx4(Row, { label: "What followed", children: (t.signals ?? []).length === 0 ? /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing in the next 15 minutes" }) : /* @__PURE__ */ jsx4("ul", { className: "flex w-full flex-col gap-1", children: (t.signals ?? []).map((s) => /* @__PURE__ */ jsxs3(
722
655
  "li",
723
656
  {
724
657
  className: "flex flex-wrap items-center gap-1.5 text-xs",
725
658
  children: [
726
659
  /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: when(s.at) }),
727
660
  /* @__PURE__ */ jsx4(Badge, { variant: correction(s) ? "secondary" : "outline", children: s.kind }),
728
- /* @__PURE__ */ jsxs2("span", { className: "text-muted-foreground", children: [
661
+ /* @__PURE__ */ jsxs3("span", { className: "text-muted-foreground", children: [
729
662
  "by ",
730
663
  s.actor || "owner"
731
664
  ] }),
@@ -734,7 +667,7 @@ function TurnDetail({ t }) {
734
667
  },
735
668
  `${s.at}-${s.kind}-${s.actor ?? ""}-${JSON.stringify(s.detail ?? {})}`
736
669
  )) }) }),
737
- corrections.length > 0 && /* @__PURE__ */ jsxs2("p", { className: "mt-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs", children: [
670
+ corrections.length > 0 && /* @__PURE__ */ jsxs3("p", { className: "mt-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2 text-xs", children: [
738
671
  "You re-pinned the context soon after this turn (",
739
672
  corrections.map((c) => c.kind).join(", "),
740
673
  "): the slot the agent chose was probably not the one you meant."
@@ -754,23 +687,23 @@ function Now() {
754
687
  useEvent("desk.changed", load);
755
688
  if (error) return /* @__PURE__ */ jsx4("p", { className: "p-4 text-xs text-destructive", children: error });
756
689
  if (!p) return /* @__PURE__ */ jsx4("p", { className: "p-4 text-xs text-muted-foreground", children: "Reading\u2026" });
757
- return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1 p-4", children: [
690
+ return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-1 p-4", children: [
758
691
  /* @__PURE__ */ jsx4("p", { className: "text-xs text-muted-foreground", children: "What a message sent now would carry. It follows the window in front." }),
759
- /* @__PURE__ */ jsx4(Row, { label: "In front", children: p.focused?.view ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
692
+ /* @__PURE__ */ jsx4(Row, { label: "In front", children: p.focused?.view ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
760
693
  /* @__PURE__ */ jsx4(Badge, { variant: "secondary", children: p.focused.view }),
761
694
  /* @__PURE__ */ jsx4("span", { className: "truncate text-xs", children: p.focused.title }),
762
695
  p.focused.ref && /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: p.focused.ref })
763
696
  ] }) : /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: "nothing" }) }),
764
- /* @__PURE__ */ jsxs2(Row, { label: "Slot", children: [
697
+ /* @__PURE__ */ jsxs3(Row, { label: "Slot", children: [
765
698
  /* @__PURE__ */ jsx4(Badge, { children: p.slot || "none" }),
766
- /* @__PURE__ */ jsxs2("span", { className: "text-xs text-muted-foreground", children: [
699
+ /* @__PURE__ */ jsxs3("span", { className: "text-xs text-muted-foreground", children: [
767
700
  "because ",
768
701
  WHY[p.why] ?? p.why
769
702
  ] })
770
703
  ] }),
771
704
  /* @__PURE__ */ jsx4(Row, { label: "Slots offered", children: chips(p.slots.map((s) => s.name)) }),
772
705
  /* @__PURE__ */ jsx4(Row, { label: "Tools to mind", children: chips(p.top_of_mind) }),
773
- /* @__PURE__ */ jsx4(Row, { label: "The block", children: /* @__PURE__ */ jsxs2("span", { className: "font-mono text-xs", children: [
706
+ /* @__PURE__ */ jsx4(Row, { label: "The block", children: /* @__PURE__ */ jsxs3("span", { className: "font-mono text-xs", children: [
774
707
  p.block.length.toLocaleString(),
775
708
  " characters"
776
709
  ] }) }),
@@ -791,9 +724,9 @@ function History() {
791
724
  }, []);
792
725
  useEffect3(load, [load]);
793
726
  const shown2 = turns?.find((t) => t.id === open) ?? turns?.[0];
794
- return /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1 flex-col", children: [
795
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 flex-wrap items-center gap-3 border-b px-3 py-2 text-xs", children: [
796
- /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-2", children: [
727
+ return /* @__PURE__ */ jsxs3("div", { className: "flex min-h-0 flex-1 flex-col", children: [
728
+ /* @__PURE__ */ jsxs3("div", { className: "flex shrink-0 flex-wrap items-center gap-3 border-b px-3 py-2 text-xs", children: [
729
+ /* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2", children: [
797
730
  /* @__PURE__ */ jsx4(
798
731
  Switch,
799
732
  {
@@ -805,10 +738,10 @@ function History() {
805
738
  "Keep the trace"
806
739
  ] }),
807
740
  /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: "On this machine only; the newest 50,000 turns." }),
808
- /* @__PURE__ */ jsxs2("div", { className: "ml-auto flex items-center gap-1", children: [
809
- /* @__PURE__ */ jsx4(Button2, { size: "sm", variant: "ghost", "aria-label": "Read the trace again", onClick: load, children: /* @__PURE__ */ jsx4(Icon, { name: "refresh-cw" }) }),
810
- /* @__PURE__ */ jsxs2(
811
- Button2,
741
+ /* @__PURE__ */ jsxs3("div", { className: "ml-auto flex items-center gap-1", children: [
742
+ /* @__PURE__ */ jsx4(Button3, { size: "sm", variant: "ghost", "aria-label": "Read the trace again", onClick: load, children: /* @__PURE__ */ jsx4(Icon, { name: "refresh-cw" }) }),
743
+ /* @__PURE__ */ jsxs3(
744
+ Button3,
812
745
  {
813
746
  size: "sm",
814
747
  variant: "outline",
@@ -822,10 +755,10 @@ function History() {
822
755
  ] })
823
756
  ] }),
824
757
  error && /* @__PURE__ */ jsx4("p", { className: "border-b px-3 py-1 text-xs text-destructive", children: error }),
825
- turns?.length === 0 ? /* @__PURE__ */ jsx4(Empty2, { className: "h-full", children: /* @__PURE__ */ jsxs2(EmptyHeader2, { children: [
758
+ turns?.length === 0 ? /* @__PURE__ */ jsx4(Empty2, { className: "h-full", children: /* @__PURE__ */ jsxs3(EmptyHeader2, { children: [
826
759
  /* @__PURE__ */ jsx4(EmptyTitle2, { children: "No turns yet" }),
827
760
  /* @__PURE__ */ jsx4(EmptyDescription2, { children: "Each message to the agent leaves a record here." })
828
- ] }) }) : /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1", children: [
761
+ ] }) }) : /* @__PURE__ */ jsxs3("div", { className: "flex min-h-0 flex-1", children: [
829
762
  /* @__PURE__ */ jsx4("div", { className: "flex w-80 shrink-0 flex-col gap-0.5 overflow-auto border-r p-1.5 @max-3xl:w-56", children: turns?.map((t) => {
830
763
  const fixed = (t.signals ?? []).some(correction);
831
764
  return /* @__PURE__ */ jsx4(
@@ -838,8 +771,8 @@ function History() {
838
771
  e.preventDefault();
839
772
  setOpen(t.id);
840
773
  },
841
- children: /* @__PURE__ */ jsxs2(ItemContent, { children: [
842
- /* @__PURE__ */ jsxs2(ItemTitle, { className: "w-full", children: [
774
+ children: /* @__PURE__ */ jsxs3(ItemContent, { children: [
775
+ /* @__PURE__ */ jsxs3(ItemTitle, { className: "w-full", children: [
843
776
  /* @__PURE__ */ jsx4(Badge, { variant: "outline", className: "font-mono", children: t.slot || "none" }),
844
777
  fixed && /* @__PURE__ */ jsx4("span", { title: "You re-pinned the context soon after this turn", children: /* @__PURE__ */ jsx4(Icon, { name: "corner-down-left", size: 12 }) }),
845
778
  t.halted && /* @__PURE__ */ jsx4(Badge, { variant: "destructive", children: "halted" }),
@@ -857,10 +790,10 @@ function History() {
857
790
  }
858
791
  function ContextInspector(_) {
859
792
  const [tab, setTab] = useState2("now");
860
- return /* @__PURE__ */ jsxs2("div", { className: "@container flex h-full min-h-0 flex-col bg-background", children: [
861
- /* @__PURE__ */ jsxs2("div", { className: "flex shrink-0 items-center gap-2 border-b px-3 py-2", children: [
793
+ return /* @__PURE__ */ jsxs3("div", { className: "@container flex h-full min-h-0 flex-col bg-background", children: [
794
+ /* @__PURE__ */ jsxs3("div", { className: "flex shrink-0 items-center gap-2 border-b px-3 py-2", children: [
862
795
  /* @__PURE__ */ jsx4("span", { className: "text-sm font-semibold", children: "Context" }),
863
- /* @__PURE__ */ jsxs2(
796
+ /* @__PURE__ */ jsxs3(
864
797
  ToggleGroup,
865
798
  {
866
799
  size: "sm",
@@ -880,7 +813,7 @@ function ContextInspector(_) {
880
813
  }
881
814
 
882
815
  // ../../web/src/desk/coreViews.tsx
883
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
816
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
884
817
  function Settings(_) {
885
818
  const [entries, setEntries] = useState3(allSettings());
886
819
  const [error, setError] = useState3("");
@@ -894,20 +827,20 @@ function Settings(_) {
894
827
  const reset = (e) => void call("DELETE", `/api/settings/${encodeURIComponent(e.full_key)}`).then(refresh);
895
828
  const scopes = [...new Set(entries.map((e) => e.scope))];
896
829
  const title = (scope) => scope === "surface" ? "Desk" : app().modules.find((m) => m.id === scope)?.title ?? scope;
897
- return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
830
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 p-4", children: [
898
831
  /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "Settings are kept in the app's database and take effect as you change them. Nothing restarts." }),
899
832
  error && /* @__PURE__ */ jsx5("p", { className: "text-destructive", children: error }),
900
- scopes.map((scope) => /* @__PURE__ */ jsxs3("section", { className: "flex flex-col", children: [
833
+ scopes.map((scope) => /* @__PURE__ */ jsxs4("section", { className: "flex flex-col", children: [
901
834
  /* @__PURE__ */ jsx5("h3", { className: "pt-2 pb-1.5 font-medium text-muted-foreground text-xs uppercase tracking-wider", children: title(scope) }),
902
- entries.filter((e) => e.scope === scope).map((e) => /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-4 border-t py-2.5", children: [
903
- /* @__PURE__ */ jsxs3("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
835
+ entries.filter((e) => e.scope === scope).map((e) => /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4 border-t py-2.5", children: [
836
+ /* @__PURE__ */ jsxs4("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
904
837
  /* @__PURE__ */ jsx5("span", { className: "font-medium", children: e.title }),
905
838
  e.about && /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground text-xs", children: e.about }),
906
839
  /* @__PURE__ */ jsx5("code", { className: "font-mono text-muted-foreground text-xs", children: e.full_key })
907
840
  ] }),
908
- /* @__PURE__ */ jsxs3("span", { className: "flex shrink-0 items-center gap-2", children: [
841
+ /* @__PURE__ */ jsxs4("span", { className: "flex shrink-0 items-center gap-2", children: [
909
842
  e.type === "bool" && /* @__PURE__ */ jsx5(Switch2, { checked: !!e.value, onCheckedChange: (on) => change(e, on), "aria-label": e.title }),
910
- e.type === "enum" && /* @__PURE__ */ jsxs3(Select, { value: String(e.value), onValueChange: (v) => change(e, v), children: [
843
+ e.type === "enum" && /* @__PURE__ */ jsxs4(Select, { value: String(e.value), onValueChange: (v) => change(e, v), children: [
911
844
  /* @__PURE__ */ jsx5(SelectTrigger, { size: "sm", "aria-label": e.title, children: /* @__PURE__ */ jsx5(SelectValue, {}) }),
912
845
  /* @__PURE__ */ jsx5(SelectContent, { children: e.options?.map((o) => /* @__PURE__ */ jsx5(SelectItem, { value: o, children: o }, o)) })
913
846
  ] }),
@@ -936,7 +869,7 @@ function Settings(_) {
936
869
  },
937
870
  String(e.value)
938
871
  ),
939
- e.set && /* @__PURE__ */ jsx5(Button3, { variant: "link", size: "xs", title: "Back to the default", onClick: () => reset(e), children: "reset" })
872
+ e.set && /* @__PURE__ */ jsx5(Button4, { variant: "link", size: "xs", title: "Back to the default", onClick: () => reset(e), children: "reset" })
940
873
  ] })
941
874
  ] }, e.full_key))
942
875
  ] }, scope))
@@ -954,9 +887,9 @@ function Layouts(_) {
954
887
  setError("");
955
888
  saveLayout(n).then(() => setName("")).catch((err) => setError(err.message));
956
889
  };
957
- return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
890
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 p-4", children: [
958
891
  /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "A layout is an arrangement you can come back to: which windows are open, how they sit, and the setup that goes with them (your mode, the agent's standing instructions, the reflexes that are on)." }),
959
- /* @__PURE__ */ jsxs3(
892
+ /* @__PURE__ */ jsxs4(
960
893
  "form",
961
894
  {
962
895
  className: "flex items-center gap-2",
@@ -974,26 +907,26 @@ function Layouts(_) {
974
907
  onChange: (e) => setName(e.target.value)
975
908
  }
976
909
  ),
977
- /* @__PURE__ */ jsx5(Button3, { type: "submit", disabled: !name.trim(), children: "Save" })
910
+ /* @__PURE__ */ jsx5(Button4, { type: "submit", disabled: !name.trim(), children: "Save" })
978
911
  ]
979
912
  }
980
913
  ),
981
914
  error && /* @__PURE__ */ jsx5("p", { className: "text-destructive", children: error }),
982
915
  layouts.length === 0 && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground text-xs", children: "No saved layouts yet." }),
983
- layouts.map((l) => /* @__PURE__ */ jsxs3(
916
+ layouts.map((l) => /* @__PURE__ */ jsxs4(
984
917
  "div",
985
918
  {
986
919
  className: "flex flex-col gap-2 rounded-lg border bg-card p-3 data-[on=true]:border-ring",
987
920
  "data-on": l.name === active,
988
921
  children: [
989
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
922
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
990
923
  /* @__PURE__ */ jsx5(Icon, { name: "layout-dashboard", size: 15 }),
991
924
  /* @__PURE__ */ jsx5("strong", { children: l.name }),
992
925
  l.name === active && /* @__PURE__ */ jsx5(Badge2, { variant: "secondary", children: "in use" }),
993
926
  /* @__PURE__ */ jsx5("span", { className: "flex-1" }),
994
- /* @__PURE__ */ jsx5(Button3, { variant: "outline", size: "sm", onClick: () => void loadLayout(l.name), children: "Arrange" }),
927
+ /* @__PURE__ */ jsx5(Button4, { variant: "outline", size: "sm", onClick: () => void loadLayout(l.name), children: "Arrange" }),
995
928
  /* @__PURE__ */ jsx5(
996
- Button3,
929
+ Button4,
997
930
  {
998
931
  variant: "outline",
999
932
  size: "sm",
@@ -1002,15 +935,15 @@ function Layouts(_) {
1002
935
  children: "Update"
1003
936
  }
1004
937
  ),
1005
- /* @__PURE__ */ jsx5(Button3, { variant: "destructive", size: "sm", onClick: () => void deleteLayout(l.name).then(refresh), children: "Delete" })
938
+ /* @__PURE__ */ jsx5(Button4, { variant: "destructive", size: "sm", onClick: () => void deleteLayout(l.name).then(refresh), children: "Delete" })
1006
939
  ] }),
1007
940
  l.about && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: l.about }),
1008
- /* @__PURE__ */ jsxs3("p", { className: "text-muted-foreground text-xs", children: [
941
+ /* @__PURE__ */ jsxs4("p", { className: "text-muted-foreground text-xs", children: [
1009
942
  l.mode,
1010
943
  " \xB7 ",
1011
944
  l.windows.map((w) => w.title || w.view).join(", ") || "no windows"
1012
945
  ] }),
1013
- l.setup && Object.keys(l.setup).length > 0 && /* @__PURE__ */ jsx5("dl", { className: "grid gap-1 text-xs [&_dd]:text-muted-foreground [&_div]:flex [&_div]:gap-2 [&_dt]:w-24 [&_dt]:shrink-0 [&_dt]:text-muted-foreground", children: Object.entries(l.setup).map(([k, v]) => /* @__PURE__ */ jsxs3("div", { children: [
946
+ l.setup && Object.keys(l.setup).length > 0 && /* @__PURE__ */ jsx5("dl", { className: "grid gap-1 text-xs [&_dd]:text-muted-foreground [&_div]:flex [&_div]:gap-2 [&_dt]:w-24 [&_dt]:shrink-0 [&_dt]:text-muted-foreground", children: Object.entries(l.setup).map(([k, v]) => /* @__PURE__ */ jsxs4("div", { children: [
1014
947
  /* @__PURE__ */ jsx5("dt", { children: k }),
1015
948
  /* @__PURE__ */ jsx5("dd", { children: typeof v === "string" ? v : JSON.stringify(v) })
1016
949
  ] }, k)) })
@@ -1025,7 +958,7 @@ function Marks(_) {
1025
958
  const refresh = useCallback3(() => void call("GET", "/api/marks").then(setMarks), []);
1026
959
  useEffect4(refresh, [refresh]);
1027
960
  useEvent("marks.changed", refresh);
1028
- return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-3 p-4", children: [
961
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 p-4", children: [
1029
962
  /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground", children: "Marks are notes pinned to a part of something, by you or the agent. These are the open ones, across every module." }),
1030
963
  marks.length === 0 && /* @__PURE__ */ jsx5("p", { className: "text-muted-foreground text-xs", children: "No open marks." }),
1031
964
  marks.map((m) => /* @__PURE__ */ jsx5(MarkCard, { mark: m }, m.id))
@@ -1033,21 +966,21 @@ function Marks(_) {
1033
966
  }
1034
967
  function MarkCard({ mark }) {
1035
968
  const [reply, setReply] = useState3("");
1036
- return /* @__PURE__ */ jsxs3(
969
+ return /* @__PURE__ */ jsxs4(
1037
970
  "div",
1038
971
  {
1039
972
  className: "flex flex-col gap-2 rounded-lg border bg-card p-3 data-[author=agent]:border-l-2 data-[author=agent]:border-l-primary",
1040
973
  "data-author": mark.author,
1041
974
  children: [
1042
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
975
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
1043
976
  /* @__PURE__ */ jsx5(Icon, { name: mark.author === "agent" ? "bot" : "user", size: 14 }),
1044
977
  /* @__PURE__ */ jsx5("code", { className: "truncate font-mono text-muted-foreground text-xs", title: mark.ref, children: mark.ref }),
1045
978
  /* @__PURE__ */ jsx5("span", { className: "flex-1" }),
1046
- /* @__PURE__ */ jsx5(Button3, { variant: "link", size: "xs", onClick: () => void resolveMark(mark.id), children: "resolve" })
979
+ /* @__PURE__ */ jsx5(Button4, { variant: "link", size: "xs", onClick: () => void resolveMark(mark.id), children: "resolve" })
1047
980
  ] }),
1048
981
  mark.quote && /* @__PURE__ */ jsx5("blockquote", { className: "border-l-2 pl-2.5 text-muted-foreground italic", children: mark.quote }),
1049
982
  /* @__PURE__ */ jsx5("p", { children: mark.body }),
1050
- mark.replies?.map((r) => /* @__PURE__ */ jsxs3("p", { className: "flex items-center gap-1.5 pl-2 text-muted-foreground", children: [
983
+ mark.replies?.map((r) => /* @__PURE__ */ jsxs4("p", { className: "flex items-center gap-1.5 pl-2 text-muted-foreground", children: [
1051
984
  /* @__PURE__ */ jsx5(Icon, { name: r.author === "agent" ? "bot" : "user", size: 12 }),
1052
985
  " ",
1053
986
  r.body
@@ -1073,7 +1006,8 @@ var coreWeb = {
1073
1006
  "surface/layouts": Layouts,
1074
1007
  "surface/marks": Marks,
1075
1008
  "surface/cards": CardsWindow,
1076
- "surface/context": ContextInspector
1009
+ "surface/context": ContextInspector,
1010
+ "surface/cite": CiteRecordView
1077
1011
  }
1078
1012
  };
1079
1013
 
@@ -1082,7 +1016,7 @@ import { applyPalette, DEFAULT_PALETTE as DEFAULT_PALETTE2, paletteById as palet
1082
1016
  import { Component as Component2, useCallback as useCallback5, useEffect as useEffect12, useMemo as useMemo4, useRef, useState as useState10 } from "react";
1083
1017
  import { AppFrame } from "@/components/ui/app-frame";
1084
1018
  import { Badge as Badge4 } from "@/components/ui/badge";
1085
- import { Button as Button7 } from "@/components/ui/button";
1019
+ import { Button as Button8 } from "@/components/ui/button";
1086
1020
  import {
1087
1021
  DropdownMenu as DropdownMenu2,
1088
1022
  DropdownMenuContent as DropdownMenuContent2,
@@ -1095,7 +1029,7 @@ import { Kbd } from "@/components/ui/kbd";
1095
1029
  import { WindowManager } from "@/components/ui/window-manager";
1096
1030
 
1097
1031
  // ../../web/src/ade/Overlay.tsx
1098
- import { useEffect as useEffect5, useState as useState4, useSyncExternalStore as useSyncExternalStore4 } from "react";
1032
+ import { useEffect as useEffect5, useState as useState4, useSyncExternalStore as useSyncExternalStore3 } from "react";
1099
1033
  import { AttentionLayer } from "@/components/ui/attention-layer";
1100
1034
  import { GuideBar } from "@/components/ui/guide-bar";
1101
1035
 
@@ -1168,8 +1102,8 @@ function applyGuide(g, report) {
1168
1102
  }
1169
1103
  const guide = toGuide(g);
1170
1104
  if (report && report.guide === g.id && report.index > 0 && (report.status === "running" || report.status === "paused")) {
1171
- const state3 = { guide, index: report.index, status: report.status, controller: "agent", history: [] };
1172
- if (hub.restoreGuide(state3)) return;
1105
+ const state2 = { guide, index: report.index, status: report.status, controller: "agent", history: [] };
1106
+ if (hub.restoreGuide(state2)) return;
1173
1107
  }
1174
1108
  try {
1175
1109
  hub.startGuide(guide, "agent");
@@ -1250,7 +1184,7 @@ var dismissAttention = () => {
1250
1184
  // ../../web/src/ade/Overlay.tsx
1251
1185
  import { jsx as jsx6 } from "react/jsx-runtime";
1252
1186
  var version2 = () => hub.getVersion();
1253
- var subscribe3 = (fn) => hub.subscribe(fn);
1187
+ var subscribe2 = (fn) => hub.subscribe(fn);
1254
1188
  function useTick(on) {
1255
1189
  const [, set2] = useState4(0);
1256
1190
  useEffect5(() => {
@@ -1279,7 +1213,7 @@ function marksOf(list2) {
1279
1213
  }
1280
1214
  function AdeAttention() {
1281
1215
  useEffect5(startAde, []);
1282
- useSyncExternalStore4(subscribe3, version2);
1216
+ useSyncExternalStore3(subscribe2, version2);
1283
1217
  const list2 = hub.attentionNow();
1284
1218
  useTick(list2.length > 0);
1285
1219
  const spot = list2.find((a) => a.style === "spotlight");
@@ -1294,7 +1228,7 @@ function AdeAttention() {
1294
1228
  );
1295
1229
  }
1296
1230
  function AdeGuide() {
1297
- useSyncExternalStore4(subscribe3, version2);
1231
+ useSyncExternalStore3(subscribe2, version2);
1298
1232
  const g = hub.guideState();
1299
1233
  if (!g || g.status === "stopped") return null;
1300
1234
  const step = g.guide.steps[g.index];
@@ -1326,7 +1260,7 @@ import { useChat, useChatBusy, useChatIds, useChatItem, useStickToBottom } from
1326
1260
  import { Bot, Check, ChevronDown, ChevronUp, Copy } from "lucide-react";
1327
1261
  import { memo, useCallback as useCallback4, useEffect as useEffect6, useLayoutEffect, useMemo as useMemo3, useState as useState5 } from "react";
1328
1262
  import { Badge as Badge3 } from "@/components/ui/badge";
1329
- import { Button as Button4 } from "@/components/ui/button";
1263
+ import { Button as Button5 } from "@/components/ui/button";
1330
1264
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
1331
1265
  import {
1332
1266
  Conversation,
@@ -1365,7 +1299,10 @@ var agentApi = {
1365
1299
  setup: () => call2("GET", "/setup"),
1366
1300
  slots: () => call2("GET", "/slots"),
1367
1301
  /** Pin a slot; "" lets the window in front choose again. */
1368
- pin: (slot) => call2("POST", "/slots/pin", { slot })
1302
+ pin: (slot) => call2("POST", "/slots/pin", { slot }),
1303
+ profiles: () => call2("GET", "/profiles"),
1304
+ /** Pin a profile: a module id, "default" (the app's own), or "auto" to let the window in front choose. */
1305
+ pinProfile: (profile) => call2("POST", "/profiles/pin", { profile })
1369
1306
  };
1370
1307
 
1371
1308
  // ../../web/src/agent/items.tsx
@@ -1373,7 +1310,7 @@ import { Markdown } from "@/components/ui/markdown";
1373
1310
  import { Message, MessageContent, MessageNotice } from "@/components/ui/message";
1374
1311
  import { Spinner } from "@/components/ui/spinner";
1375
1312
  import { Tool, ToolContent, ToolHeader, ToolInput, ToolOutput } from "@/components/ui/tool";
1376
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1313
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1377
1314
  function AskedCard({ item }) {
1378
1315
  const input = item.input ?? {};
1379
1316
  let result = {};
@@ -1384,12 +1321,19 @@ function AskedCard({ item }) {
1384
1321
  const live = useCard(result.id ?? "");
1385
1322
  if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1386
1323
  if (item.status === "running" || !input.kind) {
1387
- return /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1324
+ return /* @__PURE__ */ jsxs5(MessageNotice, { className: "flex items-center gap-1.5", children: [
1388
1325
  /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1389
1326
  " Waiting on your answer",
1390
1327
  input.title ? `: ${input.title}` : ""
1391
1328
  ] });
1392
1329
  }
1330
+ if (live && lateOpen(live)) {
1331
+ return /* @__PURE__ */ jsxs5(MessageNotice, { children: [
1332
+ "Stopped waiting for your answer",
1333
+ input.title ? ` to ${input.title}` : "",
1334
+ ". It is still in the cards above the composer: answer it there and it is sent to the agent."
1335
+ ] });
1336
+ }
1393
1337
  const card = live ?? {
1394
1338
  id: result.id ?? item.id,
1395
1339
  kind: input.kind,
@@ -1405,7 +1349,7 @@ function ShownCard({ item }) {
1405
1349
  const input = item.input ?? {};
1406
1350
  if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1407
1351
  const what = item.name === "card_update" ? input.end ? "Closed a card" : "Updated a card" : `Showed a ${input.kind ?? ""} card`;
1408
- return /* @__PURE__ */ jsxs4(MessageNotice, { children: [
1352
+ return /* @__PURE__ */ jsxs5(MessageNotice, { children: [
1409
1353
  what,
1410
1354
  input.title ? `: ${input.title}` : ""
1411
1355
  ] });
@@ -1421,14 +1365,14 @@ function GeneratedSurface({ item }) {
1421
1365
  if (item.status === "error") return /* @__PURE__ */ jsx7(ToolRow, { item });
1422
1366
  const title = input.params?.title;
1423
1367
  if (item.status === "running") {
1424
- return /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1368
+ return /* @__PURE__ */ jsxs5(MessageNotice, { className: "flex items-center gap-1.5", children: [
1425
1369
  /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1426
1370
  " Showing you",
1427
1371
  title ? `: ${title}` : " something"
1428
1372
  ] });
1429
1373
  }
1430
1374
  if (live) return /* @__PURE__ */ jsx7(CardView, { card: live });
1431
- return /* @__PURE__ */ jsxs4(MessageNotice, { children: [
1375
+ return /* @__PURE__ */ jsxs5(MessageNotice, { children: [
1432
1376
  "Showed you",
1433
1377
  title ? `: ${title}` : " a generated surface",
1434
1378
  result.status ? ` (${result.status})` : ""
@@ -1441,9 +1385,9 @@ var toolCards = {
1441
1385
  genui_show: GeneratedSurface
1442
1386
  };
1443
1387
  function ToolRow({ item }) {
1444
- return /* @__PURE__ */ jsxs4(Tool, { children: [
1388
+ return /* @__PURE__ */ jsxs5(Tool, { children: [
1445
1389
  /* @__PURE__ */ jsx7(ToolHeader, { title: item.name, status: item.status }),
1446
- /* @__PURE__ */ jsxs4(ToolContent, { children: [
1390
+ /* @__PURE__ */ jsxs5(ToolContent, { children: [
1447
1391
  /* @__PURE__ */ jsx7(ToolInput, { input: item.input }),
1448
1392
  /* @__PURE__ */ jsx7(ToolOutput, { output: item.result, error: item.status === "error" })
1449
1393
  ] })
@@ -1451,7 +1395,7 @@ function ToolRow({ item }) {
1451
1395
  }
1452
1396
  var renderers = {
1453
1397
  user: ({ item }) => item.auto ? /* @__PURE__ */ jsx7(MessageNotice, { children: item.auto }) : /* @__PURE__ */ jsx7(Message, { from: "user", children: /* @__PURE__ */ jsx7(MessageContent, { children: item.text }) }),
1454
- text: ({ item }) => item.text ? /* @__PURE__ */ jsx7(Message, { from: "assistant", children: /* @__PURE__ */ jsx7(MessageContent, { children: /* @__PURE__ */ jsx7(Markdown, { streaming: item.streaming, children: item.text }) }) }) : item.streaming ? /* @__PURE__ */ jsxs4(MessageNotice, { className: "flex items-center gap-1.5", children: [
1398
+ text: ({ item }) => item.text ? /* @__PURE__ */ jsx7(Message, { from: "assistant", children: /* @__PURE__ */ jsx7(MessageContent, { children: /* @__PURE__ */ jsx7(Markdown, { streaming: item.streaming, children: item.text }) }) }) : item.streaming ? /* @__PURE__ */ jsxs5(MessageNotice, { className: "flex items-center gap-1.5", children: [
1455
1399
  /* @__PURE__ */ jsx7(Spinner, { className: "size-3" }),
1456
1400
  " Writing\u2026"
1457
1401
  ] }) : null,
@@ -1468,7 +1412,6 @@ function ItemView({ item }) {
1468
1412
 
1469
1413
  // ../../web/src/agent/session.ts
1470
1414
  import {
1471
- createChatStore,
1472
1415
  createConversationStore,
1473
1416
  initialState
1474
1417
  } from "@hollis-labs/surface-chat";
@@ -1478,9 +1421,9 @@ function mode() {
1478
1421
  return { role: want === "viewer" ? "viewer" : "controller", stream: want === "committed" ? "committed" : "deltas" };
1479
1422
  }
1480
1423
  function createAgentSession() {
1481
- let run = null;
1424
+ let unavailable = initialState;
1482
1425
  let conv = null;
1483
- const inner = () => conv ?? run;
1426
+ const inner = () => conv;
1484
1427
  const listeners = /* @__PURE__ */ new Set();
1485
1428
  const ends = /* @__PURE__ */ new Set();
1486
1429
  const tell = () => {
@@ -1488,16 +1431,23 @@ function createAgentSession() {
1488
1431
  };
1489
1432
  const { role, stream } = mode();
1490
1433
  const boot = agentApi.setup().catch(() => null).then((setup) => {
1491
- if (setup?.wire === "conversation" && setup.agent) {
1434
+ if (setup?.ready && setup.agent) {
1492
1435
  conv = createConversationStore({
1493
- base: BASE,
1436
+ base: setup.wire_base ?? BASE,
1494
1437
  agent: setup.agent,
1495
1438
  role,
1496
1439
  stream,
1497
1440
  hostState: async () => ({ available: true, ready: setup.ready, model: setup.model })
1498
1441
  });
1499
1442
  } else {
1500
- run = createChatStore({ base: BASE });
1443
+ unavailable = {
1444
+ ...initialState,
1445
+ loaded: true,
1446
+ host: { available: true, ready: false, model: setup?.model ?? "" },
1447
+ error: setup?.reason ?? "The agent is not set up yet."
1448
+ };
1449
+ tell();
1450
+ return;
1501
1451
  }
1502
1452
  if (conv) {
1503
1453
  const leaving = conv;
@@ -1512,7 +1462,7 @@ function createAgentSession() {
1512
1462
  return store.start();
1513
1463
  });
1514
1464
  return {
1515
- get: () => inner()?.get() ?? initialState,
1465
+ get: () => inner()?.get() ?? unavailable,
1516
1466
  subscribe: (fn) => {
1517
1467
  listeners.add(fn);
1518
1468
  return () => {
@@ -1522,7 +1472,7 @@ function createAgentSession() {
1522
1472
  start: () => boot,
1523
1473
  send: async (text, how) => {
1524
1474
  await boot;
1525
- return inner().send(text, how);
1475
+ return conv ? conv.send(text, how) : false;
1526
1476
  },
1527
1477
  stop: () => inner()?.stop(),
1528
1478
  answer: async (decision) => {
@@ -1546,7 +1496,7 @@ function createAgentSession() {
1546
1496
  }
1547
1497
 
1548
1498
  // ../../web/src/agent/AgentPanel.tsx
1549
- import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1499
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1550
1500
  var shared = null;
1551
1501
  function agentSession() {
1552
1502
  if (!shared) {
@@ -1569,7 +1519,7 @@ function AgentPanel({ title = "Agent" }) {
1569
1519
  "agent.turn",
1570
1520
  (ev) => store.turnElsewhere(String(ev.data?.run_id ?? ""))
1571
1521
  );
1572
- return /* @__PURE__ */ jsxs5("div", { className: "flex h-full min-h-0 flex-col bg-background text-foreground", children: [
1522
+ return /* @__PURE__ */ jsxs6("div", { className: "flex h-full min-h-0 flex-col bg-background text-foreground", children: [
1573
1523
  /* @__PURE__ */ jsx8(ContextStrip, { store }),
1574
1524
  /* @__PURE__ */ jsx8(ChatHeader, { store, title }),
1575
1525
  /* @__PURE__ */ jsx8(Thread, { store }),
@@ -1583,12 +1533,15 @@ function ContextStrip({ store }) {
1583
1533
  const [asm, setAsm] = useState5(null);
1584
1534
  const [setup, setSetup] = useState5(null);
1585
1535
  const [slots, setSlots] = useState5([]);
1536
+ const [profiles, setProfiles] = useState5(null);
1586
1537
  const [open, setOpen] = useState5(false);
1587
1538
  const [err, setErr] = useState5("");
1588
1539
  const refresh = useCallback4(() => {
1589
1540
  agentApi.context().then(setAsm, (e) => setErr(e.message));
1590
1541
  agentApi.slots().then(setSlots, () => {
1591
1542
  });
1543
+ agentApi.profiles().then(setProfiles, () => {
1544
+ });
1592
1545
  }, []);
1593
1546
  useEffect6(() => {
1594
1547
  refresh();
@@ -1598,19 +1551,21 @@ function ContextStrip({ store }) {
1598
1551
  useEvent("agent.context", (ev) => setAsm(ev.data));
1599
1552
  useEvent("agent.note", refresh);
1600
1553
  useEvent("agent.turn", refresh);
1554
+ useEvent("agent.profile", refresh);
1601
1555
  useEffect6(() => store.onRunEnd(() => refresh()), [store, refresh]);
1602
1556
  const pin = (name) => agentApi.pin(name).then(setAsm, (e) => setErr(e.message));
1557
+ const pinProfile = (profile) => agentApi.pinProfile(profile).then(setProfiles, (e) => setErr(e.message));
1603
1558
  const top = asm?.top_of_mind ?? [];
1604
1559
  const why = asm?.why === "pinned" ? "pinned" : asm?.focused ? `from ${asm.focused.title}` : "";
1605
- return /* @__PURE__ */ jsxs5(
1560
+ return /* @__PURE__ */ jsxs6(
1606
1561
  "section",
1607
1562
  {
1608
1563
  className: "flex flex-col gap-1.5 border-b border-border px-2.5 py-2 text-xs",
1609
1564
  "aria-label": "What the agent has in mind",
1610
1565
  children: [
1611
- /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-2", children: [
1566
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-2", children: [
1612
1567
  /* @__PURE__ */ jsx8(Label, { htmlFor: "agent-slot", children: "Slot" }),
1613
- /* @__PURE__ */ jsxs5(
1568
+ /* @__PURE__ */ jsxs6(
1614
1569
  Select2,
1615
1570
  {
1616
1571
  value: asm?.slot ?? null,
@@ -1622,14 +1577,15 @@ function ContextStrip({ store }) {
1622
1577
  ]
1623
1578
  }
1624
1579
  ),
1580
+ profiles?.on && profiles.profiles.length > 0 && /* @__PURE__ */ jsx8(ProfilePicker, { state: profiles, onPick: (p) => void pinProfile(p) }),
1625
1581
  /* @__PURE__ */ jsx8("span", { className: "min-w-0 flex-1 truncate text-muted-foreground", children: why }),
1626
- asm?.why === "pinned" && /* @__PURE__ */ jsx8(Button4, { variant: "link", size: "xs", onClick: () => void pin(""), children: "unpin" }),
1627
- /* @__PURE__ */ jsxs5(Button4, { variant: "ghost", size: "xs", "aria-expanded": open, onClick: () => setOpen(!open), children: [
1582
+ asm?.why === "pinned" && /* @__PURE__ */ jsx8(Button5, { variant: "link", size: "xs", onClick: () => void pin(""), children: "unpin" }),
1583
+ /* @__PURE__ */ jsxs6(Button5, { variant: "ghost", size: "xs", "aria-expanded": open, onClick: () => setOpen(!open), children: [
1628
1584
  open ? /* @__PURE__ */ jsx8(ChevronUp, {}) : /* @__PURE__ */ jsx8(ChevronDown, {}),
1629
1585
  "context"
1630
1586
  ] })
1631
1587
  ] }),
1632
- asm && asm.slots.length > 1 && /* @__PURE__ */ jsxs5("div", { className: "text-muted-foreground", children: [
1588
+ asm && asm.slots.length > 1 && /* @__PURE__ */ jsxs6("div", { className: "text-muted-foreground", children: [
1633
1589
  "also:",
1634
1590
  " ",
1635
1591
  asm.slots.slice(1).map((s) => s.name).join(", ")
@@ -1642,14 +1598,38 @@ function ContextStrip({ store }) {
1642
1598
  }
1643
1599
  );
1644
1600
  }
1601
+ function ProfilePicker({ state: state2, onPick }) {
1602
+ const value = state2.pinned ?? "auto";
1603
+ const items = [
1604
+ { value: "auto", label: `auto (${state2.active.id || "default"})` },
1605
+ { value: "default", label: "default" },
1606
+ ...state2.profiles.map((p) => ({ value: p.id, label: p.id }))
1607
+ ];
1608
+ const active = state2.profiles.find((p) => p.id === state2.active.id);
1609
+ return /* @__PURE__ */ jsxs6(Fragment3, { children: [
1610
+ /* @__PURE__ */ jsx8(Label, { htmlFor: "agent-profile", children: "Profile" }),
1611
+ /* @__PURE__ */ jsxs6(Select2, { value, onValueChange: (v) => onPick(String(v ?? "auto")), items, children: [
1612
+ /* @__PURE__ */ jsx8(
1613
+ SelectTrigger2,
1614
+ {
1615
+ id: "agent-profile",
1616
+ size: "sm",
1617
+ title: active ? `${active.title}: ${active.description ?? ""} (${state2.active.why})` : `the app's own (${state2.active.why})`,
1618
+ children: /* @__PURE__ */ jsx8(SelectValue2, {})
1619
+ }
1620
+ ),
1621
+ /* @__PURE__ */ jsx8(SelectContent2, { children: items.map((i) => /* @__PURE__ */ jsx8(SelectItem2, { value: i.value, children: i.label }, i.value)) })
1622
+ ] })
1623
+ ] });
1624
+ }
1645
1625
  function ChatHeader({ store, title }) {
1646
1626
  const busy = useChatBusy(store);
1647
1627
  const model = useChat(store, (s) => s.host?.model ?? "");
1648
1628
  const empty = useChat(store, (s) => s.ids.length === 0);
1649
- return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 border-b border-border px-2.5 py-1.5", children: [
1629
+ return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 border-b border-border px-2.5 py-1.5", children: [
1650
1630
  /* @__PURE__ */ jsx8("span", { className: "text-sm font-semibold", children: title }),
1651
1631
  /* @__PURE__ */ jsx8("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: busy ? "working\u2026" : model }),
1652
- /* @__PURE__ */ jsx8(Button4, { variant: "ghost", size: "xs", disabled: busy || empty, onClick: () => void store.newThread(), children: "New" })
1632
+ /* @__PURE__ */ jsx8(Button5, { variant: "ghost", size: "xs", disabled: busy || empty, onClick: () => void store.newThread(), children: "New" })
1653
1633
  ] });
1654
1634
  }
1655
1635
  var Thread = memo(function Thread2({ store }) {
@@ -1658,8 +1638,8 @@ var Thread = memo(function Thread2({ store }) {
1658
1638
  const error = useChat(store, (s) => s.error);
1659
1639
  const { viewportRef, contentRef, atBottom, scrollToBottom } = useStickToBottom();
1660
1640
  useCommits("thread");
1661
- return /* @__PURE__ */ jsxs5(Conversation, { children: [
1662
- /* @__PURE__ */ jsx8(ConversationViewport, { ref: viewportRef, children: /* @__PURE__ */ jsxs5(ConversationContent, { ref: contentRef, children: [
1641
+ return /* @__PURE__ */ jsxs6(Conversation, { children: [
1642
+ /* @__PURE__ */ jsx8(ConversationViewport, { ref: viewportRef, children: /* @__PURE__ */ jsxs6(ConversationContent, { ref: contentRef, children: [
1663
1643
  off && /* @__PURE__ */ jsx8(MessageNotice2, { children: "No model is connected. The desk still works by hand." }),
1664
1644
  !off && ids.length === 0 && /* @__PURE__ */ jsx8(
1665
1645
  ConversationEmptyState,
@@ -1689,30 +1669,30 @@ function InputHolder({ store }) {
1689
1669
  const watching = store.role() === "viewer";
1690
1670
  const elsewhere = holder !== null && holder !== mine;
1691
1671
  if (!watching && !elsewhere) return null;
1692
- return /* @__PURE__ */ jsx8("div", { role: "status", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(Item2, { variant: "muted", size: "sm", children: [
1693
- /* @__PURE__ */ jsxs5(ItemContent2, { className: "min-w-0", children: [
1672
+ return /* @__PURE__ */ jsx8("div", { role: "status", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs6(Item2, { variant: "muted", size: "sm", children: [
1673
+ /* @__PURE__ */ jsxs6(ItemContent2, { className: "min-w-0", children: [
1694
1674
  /* @__PURE__ */ jsx8(ItemTitle2, { children: elsewhere ? "Another window has the input" : "This window is watching" }),
1695
1675
  /* @__PURE__ */ jsx8(ItemDescription2, { className: "text-xs", children: watching ? "It shows the conversation. Take over to type here." : "What you send here is refused until you take over." })
1696
1676
  ] }),
1697
- /* @__PURE__ */ jsx8(ItemFooter, { className: "justify-start", children: /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.takeover(), children: "Take over" }) })
1677
+ /* @__PURE__ */ jsx8(ItemFooter, { className: "justify-start", children: /* @__PURE__ */ jsx8(Button5, { variant: "outline", size: "xs", onClick: () => void store.takeover(), children: "Take over" }) })
1698
1678
  ] }) });
1699
1679
  }
1700
1680
  function ApprovalBar({ store }) {
1701
1681
  const q = useChat(store, (s) => s.approval);
1702
1682
  if (!q) return null;
1703
1683
  const input = q.input === void 0 ? "" : JSON.stringify(q.input);
1704
- return /* @__PURE__ */ jsx8("div", { role: "alertdialog", "aria-label": "Permission", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(Item2, { variant: "outline", size: "sm", children: [
1705
- /* @__PURE__ */ jsxs5(ItemContent2, { className: "min-w-0", children: [
1684
+ return /* @__PURE__ */ jsx8("div", { role: "alertdialog", "aria-label": "Permission", className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs6(Item2, { variant: "outline", size: "sm", children: [
1685
+ /* @__PURE__ */ jsxs6(ItemContent2, { className: "min-w-0", children: [
1706
1686
  /* @__PURE__ */ jsx8(ItemTitle2, { children: q.description || `Allow ${q.tool}?` }),
1707
1687
  !q.description && input && /* @__PURE__ */ jsx8(ItemDescription2, { className: "font-mono text-xs", children: input })
1708
1688
  ] }),
1709
- /* @__PURE__ */ jsxs5(ItemFooter, { className: "flex-wrap justify-start", children: [
1710
- /* @__PURE__ */ jsx8(Button4, { size: "xs", onClick: () => void store.answer("once"), children: "Allow" }),
1711
- q.standing && /* @__PURE__ */ jsxs5(Fragment3, { children: [
1712
- /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.answer("session"), children: store.durable() ? "This conversation" : "This session" }),
1713
- /* @__PURE__ */ jsx8(Button4, { variant: "outline", size: "xs", onClick: () => void store.answer("always"), children: "Always" })
1689
+ /* @__PURE__ */ jsxs6(ItemFooter, { className: "flex-wrap justify-start", children: [
1690
+ /* @__PURE__ */ jsx8(Button5, { size: "xs", onClick: () => void store.answer("once"), children: "Allow" }),
1691
+ q.standing && /* @__PURE__ */ jsxs6(Fragment3, { children: [
1692
+ /* @__PURE__ */ jsx8(Button5, { variant: "outline", size: "xs", onClick: () => void store.answer("session"), children: store.durable() ? "This conversation" : "This session" }),
1693
+ /* @__PURE__ */ jsx8(Button5, { variant: "outline", size: "xs", onClick: () => void store.answer("always"), children: "Always" })
1714
1694
  ] }),
1715
- /* @__PURE__ */ jsx8(Button4, { variant: "ghost", size: "xs", onClick: () => void store.answer("deny"), children: "Don't" })
1695
+ /* @__PURE__ */ jsx8(Button5, { variant: "ghost", size: "xs", onClick: () => void store.answer("deny"), children: "Don't" })
1716
1696
  ] })
1717
1697
  ] }) });
1718
1698
  }
@@ -1729,7 +1709,7 @@ var Composer = memo(function Composer2({ store }) {
1729
1709
  if (!ok) setDraft(text);
1730
1710
  });
1731
1711
  };
1732
- return /* @__PURE__ */ jsx8("div", { className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs5(PromptInput, { onSubmit: submit, children: [
1712
+ return /* @__PURE__ */ jsx8("div", { className: "border-t border-border p-2.5", children: /* @__PURE__ */ jsxs6(PromptInput, { onSubmit: submit, children: [
1733
1713
  /* @__PURE__ */ jsx8(
1734
1714
  PromptInputTextarea,
1735
1715
  {
@@ -1739,7 +1719,7 @@ var Composer = memo(function Composer2({ store }) {
1739
1719
  onChange: (e) => setDraft(e.target.value)
1740
1720
  }
1741
1721
  ),
1742
- /* @__PURE__ */ jsxs5(PromptInputFooter, { children: [
1722
+ /* @__PURE__ */ jsxs6(PromptInputFooter, { children: [
1743
1723
  /* @__PURE__ */ jsx8("span", { className: "text-xs text-muted-foreground", children: "Enter sends, Shift+Enter breaks the line" }),
1744
1724
  /* @__PURE__ */ jsx8(
1745
1725
  PromptInputSubmit,
@@ -1766,21 +1746,21 @@ function SetupCard({ path, reason }) {
1766
1746
  setTimeout(() => setCopied(false), 1500);
1767
1747
  });
1768
1748
  };
1769
- return /* @__PURE__ */ jsxs5(Card, { size: "sm", children: [
1770
- /* @__PURE__ */ jsxs5(CardHeader, { children: [
1749
+ return /* @__PURE__ */ jsxs6(Card, { size: "sm", children: [
1750
+ /* @__PURE__ */ jsxs6(CardHeader, { children: [
1771
1751
  /* @__PURE__ */ jsx8(CardTitle, { children: "The agent is not set up yet" }),
1772
1752
  reason && /* @__PURE__ */ jsx8("p", { className: "text-sm text-destructive", children: reason }),
1773
- /* @__PURE__ */ jsxs5(CardDescription, { children: [
1753
+ /* @__PURE__ */ jsxs6(CardDescription, { children: [
1774
1754
  "Everything else works by hand. To talk to the agent, write ",
1775
1755
  /* @__PURE__ */ jsx8("code", { className: "break-all", children: path }),
1776
1756
  ":"
1777
1757
  ] })
1778
1758
  ] }),
1779
- /* @__PURE__ */ jsxs5(CardContent, { className: "flex flex-col gap-2 text-muted-foreground", children: [
1759
+ /* @__PURE__ */ jsxs6(CardContent, { className: "flex flex-col gap-2 text-muted-foreground", children: [
1780
1760
  /* @__PURE__ */ jsx8("pre", { className: "m-0 overflow-x-auto rounded-md bg-muted p-2 font-mono text-xs text-foreground", children: text }),
1781
1761
  /* @__PURE__ */ jsx8("p", { children: "The gateway is any Anthropic-compatible endpoint; the key file holds its key. Restart the app after writing it." })
1782
1762
  ] }),
1783
- /* @__PURE__ */ jsx8(CardFooter, { children: /* @__PURE__ */ jsxs5(Button4, { variant: "outline", size: "xs", onClick: copy, children: [
1763
+ /* @__PURE__ */ jsx8(CardFooter, { children: /* @__PURE__ */ jsxs6(Button5, { variant: "outline", size: "xs", onClick: copy, children: [
1784
1764
  copied ? /* @__PURE__ */ jsx8(Check, {}) : /* @__PURE__ */ jsx8(Copy, {}),
1785
1765
  copied ? "Copied" : "Copy the example"
1786
1766
  ] }) })
@@ -1788,15 +1768,15 @@ function SetupCard({ path, reason }) {
1788
1768
  }
1789
1769
 
1790
1770
  // ../../web/src/desk/AttentionBadge.tsx
1791
- import { Button as Button5 } from "@/components/ui/button";
1771
+ import { Button as Button6 } from "@/components/ui/button";
1792
1772
 
1793
1773
  // ../../web/src/desk/attention.ts
1794
- import { useSyncExternalStore as useSyncExternalStore5 } from "react";
1795
- var state2 = { items: [], counts: {} };
1796
- var subs3 = /* @__PURE__ */ new Set();
1774
+ import { useSyncExternalStore as useSyncExternalStore4 } from "react";
1775
+ var state = { items: [], counts: {} };
1776
+ var subs2 = /* @__PURE__ */ new Set();
1797
1777
  var set = (a) => {
1798
- state2 = { items: a?.items ?? [], counts: a?.counts ?? {} };
1799
- for (const fn of subs3) fn();
1778
+ state = { items: a?.items ?? [], counts: a?.counts ?? {} };
1779
+ for (const fn of subs2) fn();
1800
1780
  };
1801
1781
  var started3 = false;
1802
1782
  function start() {
@@ -1808,12 +1788,12 @@ function start() {
1808
1788
  }
1809
1789
  function useAttention() {
1810
1790
  start();
1811
- return useSyncExternalStore5(
1791
+ return useSyncExternalStore4(
1812
1792
  (fn) => {
1813
- subs3.add(fn);
1814
- return () => subs3.delete(fn);
1793
+ subs2.add(fn);
1794
+ return () => subs2.delete(fn);
1815
1795
  },
1816
- () => state2
1796
+ () => state
1817
1797
  );
1818
1798
  }
1819
1799
  var firstItem = (a) => a.items[0];
@@ -1889,7 +1869,7 @@ function runClient(id, ui, args) {
1889
1869
  }
1890
1870
 
1891
1871
  // ../../web/src/desk/AttentionBadge.tsx
1892
- import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1872
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1893
1873
  var words = { needs_you: "need you", failed: "failed", unseen: "not seen yet" };
1894
1874
  function AttentionBadge({ ui }) {
1895
1875
  const a = useAttention();
@@ -1898,10 +1878,10 @@ function AttentionBadge({ ui }) {
1898
1878
  const needs = a.counts.needs_you ?? a.items.filter((i) => i.state === "needs_you").length;
1899
1879
  const byState = {};
1900
1880
  for (const i of a.items) byState[i.state] = (byState[i.state] ?? 0) + 1;
1901
- const summary = Object.entries(byState).map(([state3, n]) => `${n} ${words[state3] ?? state3}`).join(" \xB7 ");
1881
+ const summary = Object.entries(byState).map(([state2, n]) => `${n} ${words[state2] ?? state2}`).join(" \xB7 ");
1902
1882
  const first = a.items[0];
1903
- return /* @__PURE__ */ jsxs6(
1904
- Button5,
1883
+ return /* @__PURE__ */ jsxs7(
1884
+ Button6,
1905
1885
  {
1906
1886
  variant: needs > 0 ? "secondary" : "ghost",
1907
1887
  size: "sm",
@@ -1930,7 +1910,7 @@ import {
1930
1910
  AlertDialogHeader,
1931
1911
  AlertDialogTitle
1932
1912
  } from "@/components/ui/alert-dialog";
1933
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
1913
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1934
1914
  function ConfirmHost() {
1935
1915
  const [q, setQ] = useState6(null);
1936
1916
  useEffect7(() => {
@@ -1947,12 +1927,12 @@ function ConfirmHost() {
1947
1927
  onOpenChange: (open) => {
1948
1928
  if (!open) answer2(false);
1949
1929
  },
1950
- children: /* @__PURE__ */ jsxs7(AlertDialogContent, { size: "sm", children: [
1951
- /* @__PURE__ */ jsxs7(AlertDialogHeader, { children: [
1930
+ children: /* @__PURE__ */ jsxs8(AlertDialogContent, { size: "sm", children: [
1931
+ /* @__PURE__ */ jsxs8(AlertDialogHeader, { children: [
1952
1932
  /* @__PURE__ */ jsx10(AlertDialogTitle, { children: q?.title }),
1953
1933
  q?.message && /* @__PURE__ */ jsx10(AlertDialogDescription, { children: q.message })
1954
1934
  ] }),
1955
- /* @__PURE__ */ jsxs7(AlertDialogFooter, { children: [
1935
+ /* @__PURE__ */ jsxs8(AlertDialogFooter, { children: [
1956
1936
  /* @__PURE__ */ jsx10(AlertDialogCancel, { children: "Cancel" }),
1957
1937
  /* @__PURE__ */ jsx10(AlertDialogAction, { variant: q?.danger ? "destructive" : "default", onClick: () => answer2(true), children: q?.confirmLabel ?? "OK" })
1958
1938
  ] })
@@ -2004,7 +1984,7 @@ function useComposing(ref, id) {
2004
1984
 
2005
1985
  // ../../web/src/desk/GhostCursor.tsx
2006
1986
  import { useEffect as useEffect9, useState as useState7 } from "react";
2007
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
1987
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2008
1988
  function elementOf(p) {
2009
1989
  const win = p.window ?? deskState().wins.find((w) => w.view === p.view)?.id;
2010
1990
  if (!win) return null;
@@ -2060,7 +2040,7 @@ function GhostCursor() {
2060
2040
  };
2061
2041
  }, []);
2062
2042
  if (!at) return null;
2063
- return /* @__PURE__ */ jsxs8(
2043
+ return /* @__PURE__ */ jsxs9(
2064
2044
  "div",
2065
2045
  {
2066
2046
  "data-slot": "ghost-cursor",
@@ -2160,7 +2140,7 @@ import {
2160
2140
  CommandList,
2161
2141
  CommandShortcut
2162
2142
  } from "@/components/ui/command";
2163
- import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2143
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
2164
2144
  function Palette({ open, onOpenChange, commands }) {
2165
2145
  const [layouts, setLayouts] = useState8([]);
2166
2146
  useEffect10(() => {
@@ -2204,11 +2184,11 @@ function Palette({ open, onOpenChange, commands }) {
2204
2184
  onOpenChange,
2205
2185
  title: "Command palette",
2206
2186
  description: "Run a command, open a window or load a layout.",
2207
- children: /* @__PURE__ */ jsxs9(Command, { children: [
2187
+ children: /* @__PURE__ */ jsxs10(Command, { children: [
2208
2188
  /* @__PURE__ */ jsx12(CommandInput, { placeholder: "Run a command, open a window, load a layout\u2026" }),
2209
- /* @__PURE__ */ jsxs9(CommandList, { children: [
2189
+ /* @__PURE__ */ jsxs10(CommandList, { children: [
2210
2190
  /* @__PURE__ */ jsx12(CommandEmpty, { children: "Nothing matches." }),
2211
- sections.map((section) => /* @__PURE__ */ jsx12(CommandGroup, { heading: section, children: rows.filter((r) => r.section === section).map((r) => /* @__PURE__ */ jsxs9(CommandItem, { value: r.title, keywords: r.keywords, onSelect: () => pick(r), children: [
2191
+ sections.map((section) => /* @__PURE__ */ jsx12(CommandGroup, { heading: section, children: rows.filter((r) => r.section === section).map((r) => /* @__PURE__ */ jsxs10(CommandItem, { value: r.title, keywords: r.keywords, onSelect: () => pick(r), children: [
2212
2192
  /* @__PURE__ */ jsx12(Icon, { name: r.icon ?? "chevron-right" }),
2213
2193
  /* @__PURE__ */ jsx12("span", { children: r.title }),
2214
2194
  r.hint && /* @__PURE__ */ jsx12(CommandShortcut, { children: r.hint })
@@ -2222,7 +2202,7 @@ function Palette({ open, onOpenChange, commands }) {
2222
2202
  // ../../web/src/desk/ThemePicker.tsx
2223
2203
  import { DEFAULT_PALETTE, PALETTES, paletteById } from "@hollis-labs/surface-theme";
2224
2204
  import { useEffect as useEffect11, useState as useState9 } from "react";
2225
- import { Button as Button6 } from "@/components/ui/button";
2205
+ import { Button as Button7 } from "@/components/ui/button";
2226
2206
  import {
2227
2207
  DropdownMenu,
2228
2208
  DropdownMenuContent,
@@ -2233,7 +2213,7 @@ import {
2233
2213
  DropdownMenuSeparator,
2234
2214
  DropdownMenuTrigger
2235
2215
  } from "@/components/ui/dropdown-menu";
2236
- import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2216
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
2237
2217
  function Dots({ colors }) {
2238
2218
  return /* @__PURE__ */ jsx13("span", { className: "flex shrink-0 items-center gap-0.5", "aria-hidden": true, children: Object.entries(colors).map(([role, c]) => /* @__PURE__ */ jsx13("span", { className: "size-2 rounded-full", style: { background: c } }, role)) });
2239
2219
  }
@@ -2243,11 +2223,11 @@ function ThemePicker() {
2243
2223
  const palette = paletteById(id) ?? DEFAULT_PALETTE;
2244
2224
  const set2 = (key, value) => void setSetting(key, value).catch(() => {
2245
2225
  });
2246
- return /* @__PURE__ */ jsxs10(DropdownMenu, { children: [
2226
+ return /* @__PURE__ */ jsxs11(DropdownMenu, { children: [
2247
2227
  /* @__PURE__ */ jsx13(
2248
2228
  DropdownMenuTrigger,
2249
2229
  {
2250
- render: /* @__PURE__ */ jsxs10(Button6, { variant: "ghost", size: "sm", title: "Theme", "aria-label": `Theme: ${palette.name}`, children: [
2230
+ render: /* @__PURE__ */ jsxs11(Button7, { variant: "ghost", size: "sm", title: "Theme", "aria-label": `Theme: ${palette.name}`, children: [
2251
2231
  /* @__PURE__ */ jsx13(
2252
2232
  Dots,
2253
2233
  {
@@ -2263,10 +2243,10 @@ function ThemePicker() {
2263
2243
  ] })
2264
2244
  }
2265
2245
  ),
2266
- /* @__PURE__ */ jsxs10(DropdownMenuContent, { align: "end", className: "min-w-60", children: [
2267
- /* @__PURE__ */ jsxs10(DropdownMenuGroup, { children: [
2246
+ /* @__PURE__ */ jsxs11(DropdownMenuContent, { align: "end", className: "min-w-60", children: [
2247
+ /* @__PURE__ */ jsxs11(DropdownMenuGroup, { children: [
2268
2248
  /* @__PURE__ */ jsx13(DropdownMenuLabel, { children: "Palette" }),
2269
- /* @__PURE__ */ jsx13(DropdownMenuRadioGroup, { value: palette.id, onValueChange: (v) => set2("surface.palette", String(v)), children: PALETTES.map((p) => /* @__PURE__ */ jsxs10(DropdownMenuRadioItem, { value: p.id, children: [
2249
+ /* @__PURE__ */ jsx13(DropdownMenuRadioGroup, { value: palette.id, onValueChange: (v) => set2("surface.palette", String(v)), children: PALETTES.map((p) => /* @__PURE__ */ jsxs11(DropdownMenuRadioItem, { value: p.id, children: [
2270
2250
  /* @__PURE__ */ jsx13(
2271
2251
  Dots,
2272
2252
  {
@@ -2277,9 +2257,9 @@ function ThemePicker() {
2277
2257
  ] }, p.id)) })
2278
2258
  ] }),
2279
2259
  /* @__PURE__ */ jsx13(DropdownMenuSeparator, {}),
2280
- /* @__PURE__ */ jsxs10(DropdownMenuGroup, { children: [
2260
+ /* @__PURE__ */ jsxs11(DropdownMenuGroup, { children: [
2281
2261
  /* @__PURE__ */ jsx13(DropdownMenuLabel, { children: "Type" }),
2282
- /* @__PURE__ */ jsxs10(DropdownMenuRadioGroup, { value: type, onValueChange: (v) => set2("surface.type", String(v)), children: [
2262
+ /* @__PURE__ */ jsxs11(DropdownMenuRadioGroup, { value: type, onValueChange: (v) => set2("surface.type", String(v)), children: [
2283
2263
  /* @__PURE__ */ jsx13(DropdownMenuRadioItem, { value: "mixed", children: "Mixed (mono chrome)" }),
2284
2264
  /* @__PURE__ */ jsx13(DropdownMenuRadioItem, { value: "mono", children: "Mono everywhere" })
2285
2265
  ] })
@@ -2297,10 +2277,10 @@ function Clock() {
2297
2277
  }
2298
2278
 
2299
2279
  // ../../web/src/desk/Desktop.tsx
2300
- import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
2280
+ import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
2301
2281
  function Desktop({ modules }) {
2302
- const state3 = useDeskState();
2303
- const manifest2 = app();
2282
+ const state2 = useDeskState();
2283
+ const manifest = app();
2304
2284
  const [palette, setPalette] = useState10(false);
2305
2285
  const [menu, setMenu] = useState10(false);
2306
2286
  const [agentOpen, setAgentOpen] = useState10(() => {
@@ -2324,8 +2304,8 @@ function Desktop({ modules }) {
2324
2304
  applyPalette(paletteById2(paletteId) ?? DEFAULT_PALETTE2, document.documentElement, typeStyle);
2325
2305
  }, [paletteId, typeStyle]);
2326
2306
  useEffect12(() => {
2327
- document.title = manifest2.title;
2328
- }, [manifest2.title]);
2307
+ document.title = manifest.title;
2308
+ }, [manifest.title]);
2329
2309
  const toggleAgent = useCallback5((open) => {
2330
2310
  setAgentOpen((was) => {
2331
2311
  const next = open ?? !was;
@@ -2344,13 +2324,16 @@ function Desktop({ modules }) {
2344
2324
  useEffect12(() => {
2345
2325
  setClientRunner((id, args) => runClient(id, ui, args));
2346
2326
  }, [ui]);
2347
- const commands = useMemo4(() => [...clientCommands, ...manifest2.commands], [manifest2.commands]);
2327
+ const commands = useMemo4(() => [...clientCommands, ...manifest.commands], [manifest.commands]);
2348
2328
  useEffect12(() => {
2349
2329
  const chords = commands.flatMap((c) => {
2350
2330
  const chord = c.keys ? parseKeys(c.keys) : null;
2351
2331
  return chord ? [{ chord, id: c.id }] : [];
2352
2332
  });
2353
2333
  const onKey = (e) => {
2334
+ const own = e.target?.closest?.("[data-keys-own]")?.getAttribute("data-keys-own");
2335
+ const kept = own ? own.split(/\s+/).flatMap((k) => parseKeys(k) ?? []) : [];
2336
+ if (kept.some((c) => matches(c, e))) return;
2354
2337
  for (const { chord, id } of chords) {
2355
2338
  if (matches(chord, e)) {
2356
2339
  e.preventDefault();
@@ -2364,7 +2347,7 @@ function Desktop({ modules }) {
2364
2347
  return () => window.removeEventListener("keydown", onKey, true);
2365
2348
  }, [commands]);
2366
2349
  const windows = useMemo4(
2367
- () => state3.wins.map((w) => ({
2350
+ () => state2.wins.map((w) => ({
2368
2351
  id: w.id,
2369
2352
  title: w.title,
2370
2353
  dirty: w.dirty,
@@ -2378,8 +2361,8 @@ function Desktop({ modules }) {
2378
2361
  children: /* @__PURE__ */ jsx14(Icon, { name: "bot", size: 11 })
2379
2362
  }
2380
2363
  ) : void 0,
2381
- actions: notYetKept(w) || w.held ? /* @__PURE__ */ jsxs11(Fragment4, { children: [
2382
- w.held && /* @__PURE__ */ jsxs11(Fragment4, { children: [
2364
+ actions: notYetKept(w) || w.held ? /* @__PURE__ */ jsxs12(Fragment4, { children: [
2365
+ w.held && /* @__PURE__ */ jsxs12(Fragment4, { children: [
2383
2366
  /* @__PURE__ */ jsx14(
2384
2367
  "span",
2385
2368
  {
@@ -2389,7 +2372,7 @@ function Desktop({ modules }) {
2389
2372
  }
2390
2373
  ),
2391
2374
  /* @__PURE__ */ jsx14(
2392
- Button7,
2375
+ Button8,
2393
2376
  {
2394
2377
  variant: "ghost",
2395
2378
  size: "xs",
@@ -2403,7 +2386,7 @@ function Desktop({ modules }) {
2403
2386
  }
2404
2387
  ),
2405
2388
  /* @__PURE__ */ jsx14(
2406
- Button7,
2389
+ Button8,
2407
2390
  {
2408
2391
  variant: "ghost",
2409
2392
  size: "xs",
@@ -2418,7 +2401,7 @@ function Desktop({ modules }) {
2418
2401
  )
2419
2402
  ] }),
2420
2403
  notYetKept(w) && /* @__PURE__ */ jsx14(
2421
- Button7,
2404
+ Button8,
2422
2405
  {
2423
2406
  variant: "ghost",
2424
2407
  size: "xs",
@@ -2433,39 +2416,39 @@ function Desktop({ modules }) {
2433
2416
  )
2434
2417
  ] }) : void 0
2435
2418
  })),
2436
- [state3.wins]
2419
+ [state2.wins]
2437
2420
  );
2438
2421
  const arrange = useCallback5(
2439
2422
  (tree, focus, grabbed) => act({ type: "tree", tree, focus, id: grabbed }),
2440
2423
  []
2441
2424
  );
2442
- const menuViews = manifest2.views.filter((v) => v.menu);
2443
- const bar = /* @__PURE__ */ jsxs11(Fragment4, { children: [
2444
- /* @__PURE__ */ jsxs11("div", { className: "flex h-full min-w-0 flex-1 items-center gap-1", children: [
2445
- /* @__PURE__ */ jsxs11(DropdownMenu2, { open: menu, onOpenChange: setMenu, children: [
2425
+ const menuViews = manifest.views.filter((v) => v.menu);
2426
+ const bar = /* @__PURE__ */ jsxs12(Fragment4, { children: [
2427
+ /* @__PURE__ */ jsxs12("div", { className: "flex h-full min-w-0 flex-1 items-center gap-1", children: [
2428
+ /* @__PURE__ */ jsxs12(DropdownMenu2, { open: menu, onOpenChange: setMenu, children: [
2446
2429
  /* @__PURE__ */ jsx14(
2447
2430
  DropdownMenuTrigger2,
2448
2431
  {
2449
- render: /* @__PURE__ */ jsxs11(Button7, { variant: "ghost", size: "sm", title: "Apps", children: [
2432
+ render: /* @__PURE__ */ jsxs12(Button8, { variant: "ghost", size: "sm", title: "Apps", children: [
2450
2433
  /* @__PURE__ */ jsx14(Icon, { name: "layout-grid" }),
2451
- /* @__PURE__ */ jsx14("span", { className: "font-semibold", children: manifest2.title })
2434
+ /* @__PURE__ */ jsx14("span", { className: "font-semibold", children: manifest.title })
2452
2435
  ] })
2453
2436
  }
2454
2437
  ),
2455
- /* @__PURE__ */ jsx14(DropdownMenuContent2, { className: "min-w-56", children: menuViews.map((v) => /* @__PURE__ */ jsxs11(DropdownMenuItem, { onClick: () => void desk.open(v.id), children: [
2438
+ /* @__PURE__ */ jsx14(DropdownMenuContent2, { className: "min-w-56", children: menuViews.map((v) => /* @__PURE__ */ jsxs12(DropdownMenuItem, { onClick: () => void desk.open(v.id), children: [
2456
2439
  /* @__PURE__ */ jsx14(Icon, { name: v.icon }),
2457
2440
  /* @__PURE__ */ jsx14("span", { children: v.title }),
2458
2441
  v.module !== "surface" && /* @__PURE__ */ jsx14(DropdownMenuShortcut, { children: v.module })
2459
2442
  ] }, v.id)) })
2460
2443
  ] }),
2461
- /* @__PURE__ */ jsx14("div", { className: "ml-1 flex min-w-0 gap-0.5 overflow-hidden", children: state3.wins.map((w) => /* @__PURE__ */ jsxs11(
2462
- Button7,
2444
+ /* @__PURE__ */ jsx14("div", { className: "ml-1 flex min-w-0 gap-0.5 overflow-hidden", children: state2.wins.map((w) => /* @__PURE__ */ jsxs12(
2445
+ Button8,
2463
2446
  {
2464
- variant: w.id === state3.focus ? "secondary" : "ghost",
2447
+ variant: w.id === state2.focus ? "secondary" : "ghost",
2465
2448
  size: "sm",
2466
2449
  className: "min-w-0 max-w-44 shrink",
2467
2450
  title: w.title,
2468
- "aria-pressed": w.id === state3.focus,
2451
+ "aria-pressed": w.id === state2.focus,
2469
2452
  onClick: () => void act({ type: "focus", id: w.id }),
2470
2453
  onAuxClick: (e) => {
2471
2454
  if (e.button === 1) void closeWindow(w.id);
@@ -2478,9 +2461,9 @@ function Desktop({ modules }) {
2478
2461
  w.id
2479
2462
  )) })
2480
2463
  ] }),
2481
- /* @__PURE__ */ jsxs11("div", { className: "flex h-full shrink-0 items-center gap-1", children: [
2482
- state3.active && /* @__PURE__ */ jsxs11(
2483
- Button7,
2464
+ /* @__PURE__ */ jsxs12("div", { className: "flex h-full shrink-0 items-center gap-1", children: [
2465
+ state2.active && /* @__PURE__ */ jsxs12(
2466
+ Button8,
2484
2467
  {
2485
2468
  variant: "ghost",
2486
2469
  size: "sm",
@@ -2488,32 +2471,32 @@ function Desktop({ modules }) {
2488
2471
  onClick: () => void desk.open("surface.layouts"),
2489
2472
  children: [
2490
2473
  /* @__PURE__ */ jsx14(Icon, { name: "layout-dashboard" }),
2491
- /* @__PURE__ */ jsx14("span", { children: state3.active })
2474
+ /* @__PURE__ */ jsx14("span", { children: state2.active })
2492
2475
  ]
2493
2476
  }
2494
2477
  ),
2495
- state3.mode && /* @__PURE__ */ jsx14(Badge4, { variant: "secondary", title: "Your mode", children: state3.mode }),
2496
- /* @__PURE__ */ jsxs11(
2497
- Button7,
2478
+ state2.mode && /* @__PURE__ */ jsx14(Badge4, { variant: "secondary", title: "Your mode", children: state2.mode }),
2479
+ /* @__PURE__ */ jsxs12(
2480
+ Button8,
2498
2481
  {
2499
2482
  variant: "ghost",
2500
2483
  size: "sm",
2501
2484
  title: "Tile every window, or float them all",
2502
2485
  onClick: () => void runCommand("layout.toggle"),
2503
2486
  children: [
2504
- /* @__PURE__ */ jsx14(Icon, { name: state3.layout === "tile" ? "columns-2" : "picture-in-picture-2" }),
2505
- /* @__PURE__ */ jsx14("span", { children: state3.layout })
2487
+ /* @__PURE__ */ jsx14(Icon, { name: state2.layout === "tile" ? "columns-2" : "picture-in-picture-2" }),
2488
+ /* @__PURE__ */ jsx14("span", { children: state2.layout })
2506
2489
  ]
2507
2490
  }
2508
2491
  ),
2509
2492
  /* @__PURE__ */ jsx14(AttentionBadge, { ui }),
2510
2493
  /* @__PURE__ */ jsx14(ThemePicker, {}),
2511
- /* @__PURE__ */ jsxs11(Button7, { variant: "ghost", size: "sm", title: "Command palette", onClick: () => setPalette(true), children: [
2494
+ /* @__PURE__ */ jsxs12(Button8, { variant: "ghost", size: "sm", title: "Command palette", onClick: () => setPalette(true), children: [
2512
2495
  /* @__PURE__ */ jsx14(Icon, { name: "search" }),
2513
2496
  /* @__PURE__ */ jsx14(Kbd, { children: showKeys("cmd+k") })
2514
2497
  ] }),
2515
2498
  /* @__PURE__ */ jsx14(
2516
- Button7,
2499
+ Button8,
2517
2500
  {
2518
2501
  variant: agentOpen ? "secondary" : "ghost",
2519
2502
  size: "icon-sm",
@@ -2533,12 +2516,12 @@ function Desktop({ modules }) {
2533
2516
  )
2534
2517
  ] })
2535
2518
  ] });
2536
- return /* @__PURE__ */ jsxs11(Fragment4, { children: [
2537
- /* @__PURE__ */ jsxs11(
2519
+ return /* @__PURE__ */ jsxs12(Fragment4, { children: [
2520
+ /* @__PURE__ */ jsxs12(
2538
2521
  AppFrame,
2539
2522
  {
2540
2523
  className: "fixed inset-0 text-sm",
2541
- "data-layout": state3.layout,
2524
+ "data-layout": state2.layout,
2542
2525
  bar,
2543
2526
  side: /* @__PURE__ */ jsx14(PanelComposer, {}),
2544
2527
  showSide: agentOpen,
@@ -2553,14 +2536,14 @@ function Desktop({ modules }) {
2553
2536
  children: /* @__PURE__ */ jsx14(
2554
2537
  WindowManager,
2555
2538
  {
2556
- tree: state3.tree,
2539
+ tree: state2.tree,
2557
2540
  windows,
2558
- focus: state3.focus,
2541
+ focus: state2.focus,
2559
2542
  onArrange: arrange,
2560
2543
  onClose: (id) => void closeWindow(id),
2561
- empty: /* @__PURE__ */ jsx14(Empty3, { className: "size-full", children: /* @__PURE__ */ jsxs11(EmptyHeader3, { children: [
2562
- /* @__PURE__ */ jsx14(EmptyTitle3, { children: manifest2.title }),
2563
- /* @__PURE__ */ jsxs11(EmptyDescription3, { children: [
2544
+ empty: /* @__PURE__ */ jsx14(Empty3, { className: "size-full", children: /* @__PURE__ */ jsxs12(EmptyHeader3, { children: [
2545
+ /* @__PURE__ */ jsx14(EmptyTitle3, { children: manifest.title }),
2546
+ /* @__PURE__ */ jsxs12(EmptyDescription3, { children: [
2564
2547
  "Open something from the menu, press ",
2565
2548
  /* @__PURE__ */ jsx14(Kbd, { children: showKeys("cmd+k") }),
2566
2549
  " for the palette, or ask the agent."
@@ -2615,9 +2598,9 @@ function keepPanelWidth(px) {
2615
2598
  }, 400);
2616
2599
  }
2617
2600
  function WindowBody({ id, modules }) {
2618
- const state3 = useDeskState();
2619
- const win = state3.wins.find((w) => w.id === id);
2620
- const focused = state3.focus === id;
2601
+ const state2 = useDeskState();
2602
+ const win = state2.wins.find((w) => w.id === id);
2603
+ const focused = state2.focus === id;
2621
2604
  const module = win?.module ?? "";
2622
2605
  const api = useMemo4(() => moduleApi(module), [module]);
2623
2606
  const pub = useMemo4(() => win ? toWin(win, focused ? win.id : "") : null, [win, focused]);
@@ -2633,7 +2616,7 @@ function WindowBody({ id, modules }) {
2633
2616
  ref: body,
2634
2617
  "data-bare": !!view?.bare,
2635
2618
  "data-window": win.id,
2636
- children: /* @__PURE__ */ jsx14(Boundary2, { children: Cmp ? /* @__PURE__ */ jsx14(Cmp, { win: pub, desk, api }) : /* @__PURE__ */ jsxs11("p", { className: "p-4 text-muted-foreground", children: [
2619
+ children: /* @__PURE__ */ jsx14(Boundary2, { children: Cmp ? /* @__PURE__ */ jsx14(Cmp, { win: pub, desk, api }) : /* @__PURE__ */ jsxs12("p", { className: "p-4 text-muted-foreground", children: [
2637
2620
  "This app's page was built without the view \u201C",
2638
2621
  win.view,
2639
2622
  "\u201D. Rebuild the page with the module's web entry."
@@ -2648,10 +2631,10 @@ var Boundary2 = class extends Component2 {
2648
2631
  }
2649
2632
  render() {
2650
2633
  if (this.state.error) {
2651
- return /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-start gap-3 p-4", children: [
2634
+ return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-start gap-3 p-4", children: [
2652
2635
  /* @__PURE__ */ jsx14("p", { children: "This window failed to draw." }),
2653
2636
  /* @__PURE__ */ jsx14("pre", { className: "whitespace-pre-wrap text-destructive text-xs", children: this.state.error.message }),
2654
- /* @__PURE__ */ jsx14(Button7, { variant: "outline", size: "sm", onClick: () => this.setState({ error: null }), children: "Try again" })
2637
+ /* @__PURE__ */ jsx14(Button8, { variant: "outline", size: "sm", onClick: () => this.setState({ error: null }), children: "Try again" })
2655
2638
  ] });
2656
2639
  }
2657
2640
  return this.props.children;
@@ -2659,8 +2642,21 @@ var Boundary2 = class extends Component2 {
2659
2642
  };
2660
2643
 
2661
2644
  // ../../web/src/boot.tsx
2662
- import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
2645
+ import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
2646
+ var registered = /* @__PURE__ */ new Set();
2647
+ function registerModuleCards(modules) {
2648
+ for (const [id, m] of Object.entries(modules)) {
2649
+ for (const [key, Cmp] of Object.entries(m.cards ?? {})) {
2650
+ const [kind, version3 = "1"] = key.split("@");
2651
+ if (registered.has(`${kind}@${version3}`)) continue;
2652
+ registered.add(`${kind}@${version3}`);
2653
+ const api = moduleApi(id);
2654
+ registerCard(kind, version3, ({ card, respond: respond2 }) => /* @__PURE__ */ jsx15(Cmp, { card, respond: respond2, api }));
2655
+ }
2656
+ }
2657
+ }
2663
2658
  function Page({ modules, core }) {
2659
+ registerModuleCards(modules);
2664
2660
  const [ready, setReady] = useState11(false);
2665
2661
  const [error, setError] = useState11("");
2666
2662
  useEffect13(() => {
@@ -2668,6 +2664,7 @@ function Page({ modules, core }) {
2668
2664
  Promise.all([loadManifest(), loadSettings()]).then(() => {
2669
2665
  if (!live) return;
2670
2666
  connect();
2667
+ void initCite();
2671
2668
  setReady(true);
2672
2669
  void call("POST", "/api/events", { topic: "page.ready", data: {} }).catch(() => {
2673
2670
  });
@@ -2677,14 +2674,15 @@ function Page({ modules, core }) {
2677
2674
  };
2678
2675
  }, []);
2679
2676
  if (error)
2680
- return /* @__PURE__ */ jsxs12("div", { className: "grid h-full place-items-center text-muted-foreground", children: [
2677
+ return /* @__PURE__ */ jsxs13("div", { className: "grid h-full place-items-center text-muted-foreground", children: [
2681
2678
  "The app's server did not answer: ",
2682
2679
  error
2683
2680
  ] });
2684
2681
  if (!ready) return /* @__PURE__ */ jsx15("div", { className: "grid h-full place-items-center text-muted-foreground", children: "\u2026" });
2685
- return /* @__PURE__ */ jsxs12(Fragment5, { children: [
2682
+ return /* @__PURE__ */ jsxs13(MarkdownExtensions, { value: citeMarkdownExtensions, children: [
2686
2683
  /* @__PURE__ */ jsx15(Desktop, { modules: { ...modules, surface: { ...coreWeb, views: { ...coreWeb.views, ...core } } } }),
2687
- /* @__PURE__ */ jsx15(CardHost, {})
2684
+ /* @__PURE__ */ jsx15(CardHost, {}),
2685
+ /* @__PURE__ */ jsx15(CiteFloat, {})
2688
2686
  ] });
2689
2687
  }
2690
2688
  function mountPage(props, element = document.getElementById("root")) {