@useavalon/caelence-agent 0.2.3-canary.0 → 0.2.3-canary.2

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 (67) hide show
  1. package/README.md +7 -0
  2. package/desktop/src/App.tsx +9 -2919
  3. package/desktop/src/BubbleClip.tsx +1 -1
  4. package/desktop/src/ComposerAttach.tsx +2 -2
  5. package/desktop/src/DeskBoot.tsx +28 -0
  6. package/desktop/src/DeskChrome.tsx +360 -0
  7. package/desktop/src/DeskComposer.tsx +311 -0
  8. package/desktop/src/DeskSidebar.tsx +191 -0
  9. package/desktop/src/FilesPanel.tsx +104 -36
  10. package/desktop/src/FloatNotice.test.ts +12 -0
  11. package/desktop/src/FloatNotice.tsx +5 -2
  12. package/desktop/src/IntegrationsPanel.tsx +273 -0
  13. package/desktop/src/McpPanel.tsx +8 -8
  14. package/desktop/src/MemoryPanel.tsx +138 -0
  15. package/desktop/src/QueuePanel.tsx +123 -0
  16. package/desktop/src/SessionsPanel.tsx +174 -0
  17. package/desktop/src/SettingsPanel.tsx +181 -0
  18. package/desktop/src/SkillsPanel.tsx +28 -12
  19. package/desktop/src/TranscriptViews.tsx +637 -0
  20. package/desktop/src/api.ts +36 -0
  21. package/desktop/src/app.css +159 -11
  22. package/desktop/src/composer-files.ts +2 -2
  23. package/desktop/src/desk-keys.ts +45 -0
  24. package/desktop/src/desk-prefs.ts +29 -0
  25. package/desktop/src/desk-types.ts +92 -0
  26. package/desktop/src/desktop-turn.ts +271 -0
  27. package/desktop/src/preview-render.ts +322 -36
  28. package/desktop/src/queue.ts +1 -1
  29. package/desktop/src/session-search.test.ts +20 -0
  30. package/desktop/src/session-search.ts +13 -0
  31. package/desktop/src/session-select.test.ts +23 -0
  32. package/desktop/src/session-select.ts +32 -0
  33. package/desktop/src/useDeskDictation.ts +123 -0
  34. package/desktop/src/useDeskFiles.ts +180 -0
  35. package/desktop/src/useDeskNotice.ts +20 -0
  36. package/desktop/src/useDeskPicker.ts +189 -0
  37. package/desktop/src/useDeskPrefs.ts +30 -0
  38. package/desktop/src/useDeskRuntime.ts +109 -0
  39. package/desktop/src/useDeskSessions.ts +195 -0
  40. package/desktop/src/useDeskSlash.ts +31 -0
  41. package/desktop/src/useDeskTurns.ts +264 -0
  42. package/desktop/src/useDesktopApp.ts +286 -0
  43. package/desktop/src/user-display.ts +2 -2
  44. package/package.json +2 -2
  45. package/src/cli/openrouter-live.ts +30 -21
  46. package/src/cli/slash-dispatch.test.ts +25 -0
  47. package/src/cli/slash-dispatch.ts +41 -0
  48. package/src/cli/slash.ts +1 -0
  49. package/src/config.ts +10 -1
  50. package/src/core/run-turn.test.ts +3 -0
  51. package/src/core/run-turn.ts +74 -41
  52. package/src/desktop/bridge.test.ts +43 -0
  53. package/src/desktop/bridge.ts +91 -19
  54. package/src/desktop/uploads.test.ts +6 -0
  55. package/src/desktop/uploads.ts +178 -66
  56. package/src/index.ts +13 -0
  57. package/src/integrations/remote-mcp.ts +51 -21
  58. package/src/memory/extract.test.ts +81 -0
  59. package/src/memory/extract.ts +88 -0
  60. package/src/memory/prefs.test.ts +53 -0
  61. package/src/memory/prefs.ts +47 -0
  62. package/src/memory/prompt.ts +24 -0
  63. package/src/memory/store.test.ts +191 -0
  64. package/src/memory/store.ts +382 -0
  65. package/src/runtime.test.ts +37 -0
  66. package/src/runtime.ts +29 -1
  67. package/src/tools/local.ts +86 -39
@@ -0,0 +1,637 @@
1
+ import { ArrowUpRightIcon } from "@phosphor-icons/react/dist/csr/ArrowUpRight";
2
+ import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
3
+ import { GearIcon } from "@phosphor-icons/react/dist/csr/Gear";
4
+ import { PencilSimpleIcon } from "@phosphor-icons/react/dist/csr/PencilSimple";
5
+ import { useEffect, useState } from "react";
6
+ import {
7
+ type BridgeClient,
8
+ embedPreview,
9
+ openExternal,
10
+ openLocalFile,
11
+ type PublicIntegration,
12
+ } from "./api";
13
+ import { BubbleClip } from "./BubbleClip";
14
+ import { AttachmentThumbs } from "./ComposerAttach";
15
+ import { PipelineTrack } from "./PipelineTrack";
16
+ import { PlatformPane } from "./PlatformPane";
17
+ import { pipelineProgress } from "./pipeline";
18
+ import { formatPlatformOutput, isPlatformTool } from "./platform";
19
+ import { ReplySources } from "./ReplySources";
20
+ import { canvaViewUrl, looksLikeWebUrl, splitRichText, webHref } from "./rich-text";
21
+ import { ShimmerPhrase } from "./ShimmerPhrase";
22
+ import type { StreamLine } from "./stream";
23
+ import {
24
+ type FoldEntry,
25
+ liveStatusPhrases,
26
+ type ToolLine,
27
+ type TranscriptBlock,
28
+ thoughtSummary,
29
+ thoughtTools,
30
+ } from "./thought";
31
+ import { eventCountSuffix } from "./tool-label";
32
+ import type { DeskReady } from "./useDesktopApp";
33
+ import { userBubbleContent } from "./user-display";
34
+
35
+ const SILENT_CAPTIONS = "data:text/vtt,WEBVTT";
36
+
37
+ export function richPartKey(part: ReturnType<typeof splitRichText>[number]): string {
38
+ if (part.type === "text") return `text:${part.text}`;
39
+ if (part.type === "link") return `link:${part.href}:${part.label}`;
40
+ if (part.type === "file") return `file:${part.path}:${part.label}`;
41
+ return `image:${part.src}:${part.alt}`;
42
+ }
43
+ export function ThoughtFold(
44
+ props: Readonly<{
45
+ entries: FoldEntry[];
46
+ live: boolean;
47
+ warmupSeed?: number;
48
+ }>,
49
+ ): React.ReactElement {
50
+ const { entries, live } = props;
51
+ const tools = thoughtTools(entries);
52
+ const summary = thoughtSummary(tools, live, {
53
+ warmup: entries.length === 0,
54
+ seed: props.warmupSeed ?? 0,
55
+ });
56
+ const phrases = live ? liveStatusPhrases(tools, entries.length === 0) : [summary.headline];
57
+ const pipe = live ? pipelineProgress(tools) : undefined;
58
+ const hasBody = entries.some((entry) =>
59
+ entry.type === "note" ? entry.text.trim().length > 0 : true,
60
+ );
61
+ const headline = (
62
+ <span className="desk-thought__copy">
63
+ <span className="desk-thought__headline">
64
+ <ShimmerPhrase phrases={phrases} live={live} tone={pipe ? "pipe" : undefined} />
65
+ </span>
66
+ {pipe ? <PipelineTrack steps={pipe.steps} /> : null}
67
+ </span>
68
+ );
69
+ if (!hasBody) {
70
+ return (
71
+ <p className={`desk-thought desk-thought--plain${pipe ? " is-pipe" : ""}`}>{headline}</p>
72
+ );
73
+ }
74
+ return (
75
+ <details className={`desk-thought${pipe ? " is-pipe" : ""}`}>
76
+ <summary>{headline}</summary>
77
+ <div className="desk-thought__body">
78
+ {entries.map((entry) => {
79
+ if (entry.type === "note") {
80
+ const text = entry.text.trim();
81
+ if (!text) return null;
82
+ return (
83
+ <p key={`note-${text}`} className="desk-thought__reasoning">
84
+ {text}
85
+ </p>
86
+ );
87
+ }
88
+ return <ToolEventRow key={entry.tool.key} line={entry.tool} />;
89
+ })}
90
+ </div>
91
+ </details>
92
+ );
93
+ }
94
+
95
+ export function ToolEventRow(props: Readonly<{ line: ToolLine }>): React.ReactElement {
96
+ const { line } = props;
97
+ const count = eventCountSuffix(line.count);
98
+ return (
99
+ <article className={`desk-line desk-line--event is-${line.status}`}>
100
+ <p>
101
+ {line.status === "running" ? (
102
+ <span className="desk-event__spin" aria-hidden="true" />
103
+ ) : (
104
+ <GearIcon size={16} weight="regular" aria-hidden="true" />
105
+ )}
106
+ <span>
107
+ {line.label}
108
+ {count}
109
+ </span>
110
+ </p>
111
+ {line.status === "fail" && line.error ? (
112
+ <p className="desk-event__err">{line.error}</p>
113
+ ) : null}
114
+ </article>
115
+ );
116
+ }
117
+
118
+ export function UserTranscriptLine(
119
+ props: Readonly<{
120
+ line: Extract<StreamLine, { type: "user" }>;
121
+ editing?: string | null;
122
+ onStartEdit?: () => void;
123
+ onEditChange?: (text: string) => void;
124
+ onEditSave?: () => void;
125
+ onEditCancel?: () => void;
126
+ }>,
127
+ ): React.ReactElement {
128
+ const editing = props.editing != null;
129
+ const shown = userBubbleContent(props.line.text, props.line.attachments);
130
+ return (
131
+ <article className={`desk-line desk-line--user${editing ? " is-editing" : ""}`}>
132
+ <p className="desk-line__who">
133
+ {!editing && props.onStartEdit ? (
134
+ <button
135
+ type="button"
136
+ className="cel-btn cel-btn--quiet cel-btn--compact desk-line__edit-btn"
137
+ onClick={props.onStartEdit}
138
+ >
139
+ <PencilSimpleIcon size={16} weight="regular" />
140
+ Edit
141
+ </button>
142
+ ) : null}
143
+ <span>You</span>
144
+ </p>
145
+ <div className="desk-line__body">
146
+ {editing ? (
147
+ <>
148
+ <textarea
149
+ className="cel-input desk-compose-input"
150
+ rows={3}
151
+ value={props.editing ?? ""}
152
+ aria-label="Edit message"
153
+ onChange={(event) => props.onEditChange?.(event.target.value)}
154
+ onKeyDown={(event) => {
155
+ if (event.key === "Enter" && !event.shiftKey) {
156
+ event.preventDefault();
157
+ props.onEditSave?.();
158
+ }
159
+ if (event.key === "Escape") {
160
+ event.preventDefault();
161
+ props.onEditCancel?.();
162
+ }
163
+ }}
164
+ />
165
+ <div className="desk-line__edit-actions">
166
+ <button
167
+ type="button"
168
+ className="cel-btn cel-btn--secondary cel-btn--compact"
169
+ onClick={props.onEditSave}
170
+ >
171
+ Save
172
+ </button>
173
+ <button
174
+ type="button"
175
+ className="cel-btn cel-btn--quiet cel-btn--compact"
176
+ onClick={props.onEditCancel}
177
+ >
178
+ Cancel
179
+ </button>
180
+ </div>
181
+ </>
182
+ ) : (
183
+ <>
184
+ <AttachmentThumbs items={shown.attachments} variant="chat" />
185
+ {shown.text ? (
186
+ <BubbleClip text={shown.text}>
187
+ <p>{shown.text}</p>
188
+ </BubbleClip>
189
+ ) : null}
190
+ </>
191
+ )}
192
+ </div>
193
+ </article>
194
+ );
195
+ }
196
+
197
+ export function TranscriptLine(
198
+ props: Readonly<{
199
+ line: StreamLine;
200
+ lines: StreamLine[];
201
+ bridge: BridgeClient | null;
202
+ integrations: PublicIntegration[];
203
+ editing?: string | null;
204
+ onStartEdit?: () => void;
205
+ onEditChange?: (text: string) => void;
206
+ onEditSave?: () => void;
207
+ onEditCancel?: () => void;
208
+ onOpenUrl?: (url: string) => void;
209
+ onOpenFile?: (path: string, reveal: boolean) => void;
210
+ }>,
211
+ ): React.ReactElement {
212
+ const { line, bridge, onOpenUrl, onOpenFile } = props;
213
+ if (line.type === "user") {
214
+ return (
215
+ <UserTranscriptLine
216
+ line={line}
217
+ editing={props.editing}
218
+ onStartEdit={props.onStartEdit}
219
+ onEditChange={props.onEditChange}
220
+ onEditSave={props.onEditSave}
221
+ onEditCancel={props.onEditCancel}
222
+ />
223
+ );
224
+ }
225
+ if (line.type === "assistant") {
226
+ return (
227
+ <article className="desk-line desk-line--assistant">
228
+ <p className="desk-line__who">Agent</p>
229
+ <div className="desk-line__body">
230
+ <RichBody
231
+ text={line.text}
232
+ bridge={bridge}
233
+ onOpenUrl={onOpenUrl}
234
+ onOpenFile={onOpenFile}
235
+ />
236
+ <ReplySources
237
+ lines={props.lines}
238
+ assistantKey={line.key}
239
+ bridge={bridge}
240
+ onOpenUrl={onOpenUrl}
241
+ onOpenFile={onOpenFile}
242
+ />
243
+ </div>
244
+ </article>
245
+ );
246
+ }
247
+ if (line.type === "tool") {
248
+ return (
249
+ <ToolTranscriptLine
250
+ line={line}
251
+ bridge={bridge}
252
+ integrations={props.integrations}
253
+ onOpenUrl={onOpenUrl}
254
+ onOpenFile={onOpenFile}
255
+ />
256
+ );
257
+ }
258
+ if (line.type === "error") {
259
+ return (
260
+ <article className="desk-line desk-line--error">
261
+ <p>{line.text}</p>
262
+ </article>
263
+ );
264
+ }
265
+ if (line.type === "media") {
266
+ return <MediaTranscriptLine line={line} />;
267
+ }
268
+ return (
269
+ <article className="desk-line desk-line--system">
270
+ <p>{line.text}</p>
271
+ </article>
272
+ );
273
+ }
274
+
275
+ export function ToolTranscriptLine(
276
+ props: Readonly<{
277
+ line: Extract<StreamLine, { type: "tool" }>;
278
+ bridge: BridgeClient | null;
279
+ integrations: PublicIntegration[];
280
+ onOpenUrl?: (url: string) => void;
281
+ onOpenFile?: (path: string, reveal: boolean) => void;
282
+ }>,
283
+ ): React.ReactElement {
284
+ const { line, bridge, onOpenUrl, onOpenFile } = props;
285
+ if (isPlatformTool(line.name)) {
286
+ const body = formatPlatformOutput(line.output ?? "");
287
+ return (
288
+ <PlatformPane line={line} integrations={props.integrations}>
289
+ {body ? (
290
+ <RichBody text={body} bridge={bridge} onOpenUrl={onOpenUrl} onOpenFile={onOpenFile} />
291
+ ) : null}
292
+ </PlatformPane>
293
+ );
294
+ }
295
+ const count = eventCountSuffix(line.count);
296
+ return (
297
+ <article className={`desk-line desk-line--event is-${line.status}`}>
298
+ <p>
299
+ {line.status === "running" ? (
300
+ <span className="desk-event__spin" aria-hidden="true" />
301
+ ) : (
302
+ <GearIcon size={16} weight="regular" aria-hidden="true" />
303
+ )}
304
+ <span>
305
+ {line.label}
306
+ {count}
307
+ </span>
308
+ </p>
309
+ {line.status === "fail" && line.error ? (
310
+ <p className="desk-event__err">{line.error}</p>
311
+ ) : null}
312
+ </article>
313
+ );
314
+ }
315
+
316
+ export function MediaTranscriptLine(
317
+ props: Readonly<{ line: Extract<StreamLine, { type: "media" }> }>,
318
+ ): React.ReactElement {
319
+ const { line } = props;
320
+ const preview =
321
+ line.kind === "video" ? (
322
+ <video className="desk-preview desk-preview--img" controls src={line.src}>
323
+ <track kind="captions" srcLang="en" label="Captions" src={SILENT_CAPTIONS} />
324
+ </video>
325
+ ) : (
326
+ <img className="desk-preview desk-preview--img" src={line.src} alt={line.caption} />
327
+ );
328
+ return (
329
+ <article className="desk-line desk-line--assistant">
330
+ <p className="desk-line__who">Agent</p>
331
+ <div className="desk-line__body">
332
+ {preview}
333
+ <p className="desk-line__caption">{line.caption}</p>
334
+ </div>
335
+ </article>
336
+ );
337
+ }
338
+
339
+ export function RichBody(
340
+ props: Readonly<{
341
+ text: string;
342
+ bridge: BridgeClient | null;
343
+ onOpenUrl?: (url: string) => void;
344
+ onOpenFile?: (path: string, reveal: boolean) => void;
345
+ }>,
346
+ ): React.ReactElement {
347
+ const parts = splitRichText(props.text);
348
+ return (
349
+ <div className="desk-rich">
350
+ {parts.map((part, index) => {
351
+ if (part.type === "text") {
352
+ const next = parts.at(index + 1);
353
+ if (next?.type === "image" && /^\s*Preview:?\s*$/i.test(part.text)) return null;
354
+ return <span key={richPartKey(part)}>{part.text}</span>;
355
+ }
356
+ if (part.type === "file") {
357
+ return (
358
+ <FileLink
359
+ key={richPartKey(part)}
360
+ path={part.path}
361
+ label={part.label}
362
+ onOpenFile={props.onOpenFile}
363
+ onOpenUrl={props.onOpenUrl}
364
+ />
365
+ );
366
+ }
367
+ if (part.type === "image") {
368
+ const viewHref = [...parts]
369
+ .reverse()
370
+ .find(
371
+ (item): item is Extract<typeof item, { type: "link" }> =>
372
+ item.type === "link" && item.href.includes("canva.com/d/"),
373
+ )?.href;
374
+ return (
375
+ <PreviewFrame
376
+ key={richPartKey(part)}
377
+ src={part.src}
378
+ title={part.alt}
379
+ viewHref={viewHref}
380
+ bridge={props.bridge}
381
+ onOpenUrl={props.onOpenUrl}
382
+ />
383
+ );
384
+ }
385
+ return (
386
+ <ExternalLink
387
+ key={richPartKey(part)}
388
+ href={part.href}
389
+ label={part.label}
390
+ onOpenUrl={props.onOpenUrl}
391
+ />
392
+ );
393
+ })}
394
+ </div>
395
+ );
396
+ }
397
+
398
+ export function FileLink(
399
+ props: Readonly<{
400
+ path: string;
401
+ label: string;
402
+ onOpenFile?: (path: string, reveal: boolean) => void;
403
+ onOpenUrl?: (url: string) => void;
404
+ }>,
405
+ ): React.ReactElement {
406
+ if (looksLikeWebUrl(props.path)) {
407
+ return (
408
+ <ExternalLink href={webHref(props.path)} label={props.label} onOpenUrl={props.onOpenUrl} />
409
+ );
410
+ }
411
+ return (
412
+ <span className="desk-file">
413
+ <button
414
+ type="button"
415
+ className="desk-link"
416
+ onClick={() => props.onOpenFile?.(props.path, false)}
417
+ >
418
+ {props.label}
419
+ </button>
420
+ <button
421
+ type="button"
422
+ className="desk-link desk-link--icon"
423
+ aria-label={`Show ${props.label} in folder`}
424
+ onClick={() => props.onOpenFile?.(props.path, true)}
425
+ >
426
+ <FolderSimpleIcon size={16} weight="regular" aria-hidden="true" />
427
+ </button>
428
+ </span>
429
+ );
430
+ }
431
+
432
+ export function ExternalLink(
433
+ props: Readonly<{
434
+ href: string;
435
+ label: string;
436
+ onOpenUrl?: (url: string) => void;
437
+ }>,
438
+ ): React.ReactElement {
439
+ return (
440
+ <button type="button" className="desk-link" onClick={() => props.onOpenUrl?.(props.href)}>
441
+ <span>{props.label}</span>
442
+ <ArrowUpRightIcon size={16} weight="regular" aria-hidden="true" />
443
+ </button>
444
+ );
445
+ }
446
+
447
+ export function PreviewFrame(
448
+ props: Readonly<{
449
+ src: string;
450
+ title: string;
451
+ viewHref?: string;
452
+ bridge: BridgeClient | null;
453
+ onOpenUrl?: (url: string) => void;
454
+ }>,
455
+ ): React.ReactElement {
456
+ const [blobSrc, setBlobSrc] = useState<string | null>(null);
457
+ const [mode, setMode] = useState<"load" | "frame" | "expired">("load");
458
+ const openHref = props.viewHref ?? canvaViewUrl(props.src) ?? props.src;
459
+
460
+ useEffect(() => {
461
+ let objectUrl: string | undefined;
462
+ let cancelled = false;
463
+ setMode("load");
464
+ setBlobSrc(null);
465
+ void (async () => {
466
+ try {
467
+ if (!props.bridge) {
468
+ if (!cancelled) setMode("expired");
469
+ return;
470
+ }
471
+ const blob = await embedPreview(props.bridge, props.src);
472
+ if (cancelled) return;
473
+ objectUrl = URL.createObjectURL(blob);
474
+ if (cancelled) {
475
+ URL.revokeObjectURL(objectUrl);
476
+ return;
477
+ }
478
+ setBlobSrc(objectUrl);
479
+ setMode("frame");
480
+ } catch {
481
+ if (!cancelled) setMode("expired");
482
+ }
483
+ })();
484
+ return () => {
485
+ cancelled = true;
486
+ if (objectUrl) URL.revokeObjectURL(objectUrl);
487
+ };
488
+ }, [props.bridge, props.src]);
489
+
490
+ if (mode === "expired") {
491
+ return (
492
+ <div className="desk-preview desk-preview--empty">
493
+ <p>Preview expired</p>
494
+ <p>The thumbnail link is no longer valid.</p>
495
+ <button
496
+ type="button"
497
+ className="cel-btn cel-btn--tertiary cel-btn--compact"
498
+ onClick={() => props.onOpenUrl?.(openHref)}
499
+ >
500
+ Open in Canva
501
+ </button>
502
+ </div>
503
+ );
504
+ }
505
+ if (mode === "frame" && blobSrc) {
506
+ return <img className="desk-preview desk-preview--img" src={blobSrc} alt={props.title} />;
507
+ }
508
+ return (
509
+ <div className="desk-preview desk-preview--empty" aria-busy="true">
510
+ <span className="cel-chip cel-chip--run">
511
+ <span className="cel-chip__spin" aria-hidden="true" />
512
+ {"Preview"}
513
+ </span>
514
+ </div>
515
+ );
516
+ }
517
+
518
+ export function DeskTranscript(
519
+ props: Readonly<{
520
+ desk: DeskReady;
521
+ turnRunning: boolean;
522
+ transcriptBlocks: TranscriptBlock[];
523
+ thoughtPending: boolean;
524
+ warmupSeed: number;
525
+ }>,
526
+ ): React.ReactElement {
527
+ const empty = props.desk.lines.length === 0 && !props.thoughtPending;
528
+ return (
529
+ <div className="desk-transcript" ref={props.desk.transcriptRef}>
530
+ {empty ? (
531
+ <p className="desk-hint">Type a message, drop files, or / for commands</p>
532
+ ) : (
533
+ <DeskTranscriptBlocks
534
+ desk={props.desk}
535
+ turnRunning={props.turnRunning}
536
+ transcriptBlocks={props.transcriptBlocks}
537
+ thoughtPending={props.thoughtPending}
538
+ warmupSeed={props.warmupSeed}
539
+ />
540
+ )}
541
+ </div>
542
+ );
543
+ }
544
+
545
+ export function DeskTranscriptBlocks(
546
+ props: Readonly<{
547
+ desk: DeskReady;
548
+ turnRunning: boolean;
549
+ transcriptBlocks: TranscriptBlock[];
550
+ thoughtPending: boolean;
551
+ warmupSeed: number;
552
+ }>,
553
+ ): React.ReactElement {
554
+ return (
555
+ <>
556
+ {props.transcriptBlocks.map((block, index) => (
557
+ <DeskTranscriptBlock
558
+ key={transcriptBlockKey(block, index)}
559
+ desk={props.desk}
560
+ block={block}
561
+ index={index}
562
+ turnRunning={props.turnRunning}
563
+ />
564
+ ))}
565
+ {props.thoughtPending ? (
566
+ <ThoughtFold key="thinking" entries={[]} live warmupSeed={props.warmupSeed} />
567
+ ) : null}
568
+ </>
569
+ );
570
+ }
571
+
572
+ export function transcriptBlockKey(block: TranscriptBlock, index: number): string {
573
+ if (block.type === "thought") return thoughtTools(block.entries)[0]?.key ?? `thought-${index}`;
574
+ return block.line.key;
575
+ }
576
+
577
+ export function DeskTranscriptBlock(
578
+ props: Readonly<{
579
+ desk: DeskReady;
580
+ block: TranscriptBlock;
581
+ index: number;
582
+ turnRunning: boolean;
583
+ }>,
584
+ ): React.ReactElement {
585
+ const { desk, block, index, turnRunning } = props;
586
+ if (block.type === "thought") {
587
+ return (
588
+ <ThoughtFold
589
+ key={thoughtTools(block.entries)[0]?.key ?? `thought-${index}`}
590
+ entries={block.entries}
591
+ live={turnRunning && block.live}
592
+ />
593
+ );
594
+ }
595
+ const line = block.line;
596
+ const editing =
597
+ line.type === "user" && desk.editingUser?.index === line.userTurnIndex
598
+ ? desk.editingUser.text
599
+ : null;
600
+ return (
601
+ <TranscriptLine
602
+ key={line.key}
603
+ line={line}
604
+ lines={desk.lines}
605
+ bridge={desk.bridge}
606
+ integrations={desk.integrations}
607
+ editing={editing}
608
+ onStartEdit={
609
+ line.type === "user"
610
+ ? () => {
611
+ const shown = userBubbleContent(line.text, line.attachments);
612
+ desk.setEditingUser({
613
+ index: line.userTurnIndex,
614
+ text: shown.text,
615
+ suffix: shown.suffix,
616
+ });
617
+ }
618
+ : undefined
619
+ }
620
+ onEditChange={(text) =>
621
+ desk.setEditingUser((current) => (current ? { ...current, text } : current))
622
+ }
623
+ onEditSave={() => void desk.commitEdit()}
624
+ onEditCancel={() => desk.setEditingUser(null)}
625
+ onOpenUrl={(url) => {
626
+ void openExternal(url, desk.bridge).catch((err: unknown) => {
627
+ desk.noticeError(err);
628
+ });
629
+ }}
630
+ onOpenFile={(path, reveal) => {
631
+ void openLocalFile(path, reveal, desk.bridge).catch((err: unknown) => {
632
+ desk.noticeError(err);
633
+ });
634
+ }}
635
+ />
636
+ );
637
+ }
@@ -166,6 +166,7 @@ export interface DesktopSettings {
166
166
  googleOAuthHint: string;
167
167
  hasMicrosoftOAuth: boolean;
168
168
  microsoftOAuthHint: string;
169
+ memoryEnabled: boolean;
169
170
  }
170
171
 
171
172
  export interface PublicIntegration {
@@ -184,6 +185,30 @@ export function getSettings(bridge: BridgeClient): Promise<DesktopSettings> {
184
185
  return request(bridge, "/settings");
185
186
  }
186
187
 
188
+ export interface PublicMemoryFact {
189
+ id: string;
190
+ text: string;
191
+ scope: "user" | "project";
192
+ createdAt: string;
193
+ pinned?: boolean;
194
+ }
195
+
196
+ export interface MemoryState {
197
+ enabled: boolean;
198
+ facts: PublicMemoryFact[];
199
+ }
200
+
201
+ export function getMemory(bridge: BridgeClient): Promise<MemoryState> {
202
+ return request(bridge, "/memory");
203
+ }
204
+
205
+ export function saveMemory(
206
+ bridge: BridgeClient,
207
+ body: { enabled?: boolean; delete?: string; pin?: string },
208
+ ): Promise<{ ok: boolean; path?: string } & MemoryState> {
209
+ return request(bridge, "/memory", { method: "POST", body: JSON.stringify(body) });
210
+ }
211
+
187
212
  export function getIntegrations(bridge: BridgeClient): Promise<{ items: PublicIntegration[] }> {
188
213
  return request(bridge, "/integrations");
189
214
  }
@@ -336,6 +361,16 @@ export function openPath(
336
361
  });
337
362
  }
338
363
 
364
+ export function deleteUploads(
365
+ bridge: BridgeClient,
366
+ rels: readonly string[],
367
+ ): Promise<{ ok: boolean; state: DesktopState }> {
368
+ return request(bridge, "/uploads/delete", {
369
+ method: "POST",
370
+ body: JSON.stringify({ rels }),
371
+ });
372
+ }
373
+
339
374
  export function readFilePreview(
340
375
  bridge: BridgeClient,
341
376
  path: string,
@@ -383,6 +418,7 @@ export function saveSettings(
383
418
  googleClientSecret?: string;
384
419
  microsoftClientId?: string;
385
420
  microsoftClientSecret?: string;
421
+ memoryEnabled?: boolean;
386
422
  },
387
423
  ): Promise<
388
424
  {