@useavalon/caelence-agent 0.2.2-canary.4 → 0.2.2-canary.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/desktop/src/App.tsx +143 -33
- package/desktop/src/BubbleClip.tsx +58 -0
- package/desktop/src/ComposerAttach.tsx +2 -26
- package/desktop/src/FilesPanel.tsx +68 -0
- package/desktop/src/PlatformPane.tsx +98 -0
- package/desktop/src/SkillsPanel.tsx +0 -7
- package/desktop/src/api.ts +6 -1
- package/desktop/src/app.css +906 -47
- package/desktop/src/clip.test.ts +16 -0
- package/desktop/src/clip.ts +26 -0
- package/desktop/src/composer-files.test.ts +2 -0
- package/desktop/src/composer-files.ts +10 -0
- package/desktop/src/platform.test.ts +30 -0
- package/desktop/src/platform.ts +76 -0
- package/desktop/src/rich-text.test.ts +26 -0
- package/desktop/src/rich-text.ts +51 -2
- package/desktop/src/stream.ts +1 -0
- package/desktop/src/styles/primitives.css +6 -3
- package/desktop/src/user-display.test.ts +42 -0
- package/desktop/src/user-display.ts +20 -0
- package/package.json +1 -1
- package/src/cli/models.ts +3 -1
- package/src/cli/openrouter-live.test.ts +29 -0
- package/src/cli/openrouter-live.ts +9 -1
- package/src/cli/tui.tsx +40 -5
- package/src/core/approval.test.ts +22 -0
- package/src/core/approval.ts +20 -0
- package/src/desktop/bridge.ts +35 -12
- package/src/desktop/upload-message.test.ts +53 -0
- package/src/desktop/upload-message.ts +74 -0
- package/src/desktop/uploads.test.ts +34 -0
- package/src/desktop/uploads.ts +178 -13
- package/src/index.ts +1 -0
- package/src/init.test.ts +21 -0
- package/src/runtime.ts +6 -1
package/desktop/src/App.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArrowUpRightIcon } from "@phosphor-icons/react/dist/csr/ArrowUpRight";
|
|
2
2
|
import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
|
|
3
3
|
import { CheckIcon } from "@phosphor-icons/react/dist/csr/Check";
|
|
4
|
+
import { FileIcon } from "@phosphor-icons/react/dist/csr/File";
|
|
4
5
|
import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
|
|
5
6
|
import { GearIcon } from "@phosphor-icons/react/dist/csr/Gear";
|
|
6
7
|
import { MicrophoneIcon } from "@phosphor-icons/react/dist/csr/Microphone";
|
|
@@ -66,6 +67,7 @@ import {
|
|
|
66
67
|
startTurn,
|
|
67
68
|
transcribe,
|
|
68
69
|
} from "./api";
|
|
70
|
+
import { BubbleClip } from "./BubbleClip";
|
|
69
71
|
import { AttachmentThumbs } from "./ComposerAttach";
|
|
70
72
|
import {
|
|
71
73
|
type ComposerAttachment,
|
|
@@ -85,11 +87,14 @@ import {
|
|
|
85
87
|
isMicPermissionDenied,
|
|
86
88
|
pickRecorderMime,
|
|
87
89
|
} from "./dictation";
|
|
90
|
+
import { FilesPanel, homePath } from "./FilesPanel";
|
|
88
91
|
import { FloatNotice } from "./FloatNotice";
|
|
89
92
|
import { integrationMatches } from "./integration-search";
|
|
90
93
|
import { LogoMark } from "./LogoMark";
|
|
91
94
|
import { McpPanel } from "./McpPanel";
|
|
95
|
+
import { PlatformPane } from "./PlatformPane";
|
|
92
96
|
import { pickerKeyAction, pickerStartIndex, stepIndex } from "./picker-nav";
|
|
97
|
+
import { formatPlatformOutput, isPlatformTool } from "./platform";
|
|
93
98
|
import {
|
|
94
99
|
enqueueMessage,
|
|
95
100
|
type QueuedMessage,
|
|
@@ -116,10 +121,11 @@ import {
|
|
|
116
121
|
thoughtTools,
|
|
117
122
|
} from "./thought";
|
|
118
123
|
import { eventCountSuffix } from "./tool-label";
|
|
124
|
+
import { joinUploadDisplay, userBubbleContent } from "./user-display";
|
|
119
125
|
|
|
120
126
|
type ThemeChoice = "system" | "light" | "dark";
|
|
121
127
|
type UiStatus = "boot" | "idle" | "running" | "approval" | "picker";
|
|
122
|
-
type MainView = "chat" | "settings" | "integrations" | "skills";
|
|
128
|
+
type MainView = "chat" | "settings" | "integrations" | "skills" | "files";
|
|
123
129
|
|
|
124
130
|
interface PickerState {
|
|
125
131
|
title: string;
|
|
@@ -141,6 +147,14 @@ interface PendingApproval {
|
|
|
141
147
|
input: Record<string, unknown>;
|
|
142
148
|
}
|
|
143
149
|
|
|
150
|
+
function isUploadEditPending(pending: PendingApproval): boolean {
|
|
151
|
+
return (
|
|
152
|
+
(pending.toolName === "edit_file" || pending.toolName === "write_file") &&
|
|
153
|
+
typeof pending.input.originalPath === "string" &&
|
|
154
|
+
pending.input.originalPath.trim().length > 0
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
144
158
|
function pickerSelectedId(kind: SlashPickerKind, current: DesktopState): string | undefined {
|
|
145
159
|
if (kind === "model") return current.modelId;
|
|
146
160
|
if (kind === "mode") return current.mode;
|
|
@@ -154,6 +168,7 @@ function mainViewTitle(view: MainView): string {
|
|
|
154
168
|
if (view === "settings") return "Settings";
|
|
155
169
|
if (view === "integrations") return "Integrations";
|
|
156
170
|
if (view === "skills") return "Skills";
|
|
171
|
+
if (view === "files") return "Files";
|
|
157
172
|
return "Chat";
|
|
158
173
|
}
|
|
159
174
|
|
|
@@ -277,10 +292,12 @@ function DeskSidePanel(
|
|
|
277
292
|
bridge: BridgeClient | null;
|
|
278
293
|
theme: ThemeChoice;
|
|
279
294
|
skillQuery: string;
|
|
295
|
+
uploads: Array<{ name: string; rel: string; sourcePath?: string }>;
|
|
280
296
|
onTheme: (theme: ThemeChoice) => void;
|
|
281
297
|
onSaved: (state: DesktopState) => void;
|
|
282
298
|
onNotice: (text: string) => void;
|
|
283
299
|
onSkillQuery: (value: string) => void;
|
|
300
|
+
onOpenFile: (path: string, reveal: boolean) => void;
|
|
284
301
|
}>,
|
|
285
302
|
): React.ReactElement | null {
|
|
286
303
|
if (!props.bridge) return null;
|
|
@@ -308,6 +325,9 @@ function DeskSidePanel(
|
|
|
308
325
|
/>
|
|
309
326
|
);
|
|
310
327
|
}
|
|
328
|
+
if (props.view === "files") {
|
|
329
|
+
return <FilesPanel items={props.uploads} onOpen={props.onOpenFile} />;
|
|
330
|
+
}
|
|
311
331
|
return null;
|
|
312
332
|
}
|
|
313
333
|
|
|
@@ -437,8 +457,13 @@ export function App(): React.ReactElement {
|
|
|
437
457
|
const [pending, setPending] = useState<PendingApproval | null>(null);
|
|
438
458
|
const [listening, setListening] = useState(false);
|
|
439
459
|
const [queue, setQueue] = useState<QueuedMessage[]>([]);
|
|
440
|
-
const [editingUser, setEditingUser] = useState<{
|
|
460
|
+
const [editingUser, setEditingUser] = useState<{
|
|
461
|
+
index: number;
|
|
462
|
+
text: string;
|
|
463
|
+
suffix?: string;
|
|
464
|
+
} | null>(null);
|
|
441
465
|
const [editingQueuedId, setEditingQueuedId] = useState<string | null>(null);
|
|
466
|
+
const [integrations, setIntegrations] = useState<PublicIntegration[]>([]);
|
|
442
467
|
const [notice, setNotice] = useState<{ text: string; id: number } | null>(null);
|
|
443
468
|
const [attachments, setAttachments] = useState<ComposerAttachment[]>([]);
|
|
444
469
|
const [fileDrag, setFileDrag] = useState(false);
|
|
@@ -522,6 +547,13 @@ export function App(): React.ReactElement {
|
|
|
522
547
|
};
|
|
523
548
|
}, []);
|
|
524
549
|
|
|
550
|
+
useEffect(() => {
|
|
551
|
+
if (!bridge) return;
|
|
552
|
+
void getIntegrations(bridge)
|
|
553
|
+
.then((result) => setIntegrations(result.items))
|
|
554
|
+
.catch(() => undefined);
|
|
555
|
+
}, [bridge]);
|
|
556
|
+
|
|
525
557
|
useEffect(() => {
|
|
526
558
|
const node = transcriptRef.current;
|
|
527
559
|
if (node) node.scrollTop = node.scrollHeight;
|
|
@@ -919,8 +951,8 @@ export function App(): React.ReactElement {
|
|
|
919
951
|
|
|
920
952
|
const commitEdit = useCallback(async () => {
|
|
921
953
|
if (!bridge || !editingUser) return;
|
|
922
|
-
const text = editingUser.text.
|
|
923
|
-
if (!text) return;
|
|
954
|
+
const text = joinUploadDisplay(editingUser.text, editingUser.suffix);
|
|
955
|
+
if (!text.trim()) return;
|
|
924
956
|
const index = editingUser.index;
|
|
925
957
|
setEditingUser(null);
|
|
926
958
|
skipDrainRef.current = true;
|
|
@@ -1118,7 +1150,7 @@ export function App(): React.ReactElement {
|
|
|
1118
1150
|
}, [renamingId, sessionMenu]);
|
|
1119
1151
|
|
|
1120
1152
|
const decide = useCallback(
|
|
1121
|
-
async (decision: "yes" | "no" | "always") => {
|
|
1153
|
+
async (decision: "yes" | "no" | "always" | "copy" | "original") => {
|
|
1122
1154
|
if (!bridge || !pending) return;
|
|
1123
1155
|
await approve(bridge, {
|
|
1124
1156
|
callId: pending.callId,
|
|
@@ -1419,6 +1451,15 @@ export function App(): React.ReactElement {
|
|
|
1419
1451
|
</ul>
|
|
1420
1452
|
)}
|
|
1421
1453
|
</section>
|
|
1454
|
+
<button
|
|
1455
|
+
type="button"
|
|
1456
|
+
className={`desk-settings-btn ${view === "files" ? "is-on" : ""}`}
|
|
1457
|
+
aria-label="Files"
|
|
1458
|
+
onClick={() => setView((current) => (current === "files" ? "chat" : "files"))}
|
|
1459
|
+
>
|
|
1460
|
+
<FileIcon size={16} weight="regular" />
|
|
1461
|
+
<span>Files</span>
|
|
1462
|
+
</button>
|
|
1422
1463
|
<button
|
|
1423
1464
|
type="button"
|
|
1424
1465
|
className={`desk-settings-btn ${view === "skills" ? "is-on" : ""}`}
|
|
@@ -1475,10 +1516,16 @@ export function App(): React.ReactElement {
|
|
|
1475
1516
|
bridge={bridge}
|
|
1476
1517
|
theme={theme}
|
|
1477
1518
|
skillQuery={skillQuery}
|
|
1519
|
+
uploads={state.uploads ?? []}
|
|
1478
1520
|
onTheme={setTheme}
|
|
1479
1521
|
onSaved={(next) => setState(next)}
|
|
1480
1522
|
onNotice={showNotice}
|
|
1481
1523
|
onSkillQuery={setSkillQuery}
|
|
1524
|
+
onOpenFile={(path, reveal) => {
|
|
1525
|
+
void openLocalFile(path, reveal, bridge).catch((err: unknown) => {
|
|
1526
|
+
noticeError(err);
|
|
1527
|
+
});
|
|
1528
|
+
}}
|
|
1482
1529
|
/>
|
|
1483
1530
|
) : (
|
|
1484
1531
|
<div className="desk-transcript" ref={transcriptRef}>
|
|
@@ -1503,6 +1550,7 @@ export function App(): React.ReactElement {
|
|
|
1503
1550
|
key={line.key}
|
|
1504
1551
|
line={line}
|
|
1505
1552
|
bridge={bridge}
|
|
1553
|
+
integrations={integrations}
|
|
1506
1554
|
editing={
|
|
1507
1555
|
line.type === "user" && editingUser?.index === line.userTurnIndex
|
|
1508
1556
|
? editingUser.text
|
|
@@ -1510,7 +1558,14 @@ export function App(): React.ReactElement {
|
|
|
1510
1558
|
}
|
|
1511
1559
|
onStartEdit={
|
|
1512
1560
|
line.type === "user"
|
|
1513
|
-
? () =>
|
|
1561
|
+
? () => {
|
|
1562
|
+
const shown = userBubbleContent(line.text, line.attachments);
|
|
1563
|
+
setEditingUser({
|
|
1564
|
+
index: line.userTurnIndex,
|
|
1565
|
+
text: shown.text,
|
|
1566
|
+
suffix: shown.suffix,
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1514
1569
|
: undefined
|
|
1515
1570
|
}
|
|
1516
1571
|
onEditChange={(text) =>
|
|
@@ -1541,31 +1596,70 @@ export function App(): React.ReactElement {
|
|
|
1541
1596
|
|
|
1542
1597
|
{view === "chat" && pending ? (
|
|
1543
1598
|
<section className="desk-approve" aria-label="Approval needed">
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1599
|
+
{isUploadEditPending(pending) ? (
|
|
1600
|
+
<>
|
|
1601
|
+
<p>Edit this file where?</p>
|
|
1602
|
+
<pre className="cel-code">
|
|
1603
|
+
{typeof pending.input.fileName === "string" ? pending.input.fileName : "File"}
|
|
1604
|
+
{"\n"}Copy:{" "}
|
|
1605
|
+
{typeof pending.input.copyPath === "string"
|
|
1606
|
+
? pending.input.copyPath
|
|
1607
|
+
: approvalPreview}
|
|
1608
|
+
{"\n"}Original: {homePath(String(pending.input.originalPath))}
|
|
1609
|
+
</pre>
|
|
1610
|
+
<div className="desk-approve-actions">
|
|
1611
|
+
<button
|
|
1612
|
+
type="button"
|
|
1613
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1614
|
+
onClick={() => void decide("copy")}
|
|
1615
|
+
>
|
|
1616
|
+
Copy
|
|
1617
|
+
</button>
|
|
1618
|
+
<button
|
|
1619
|
+
type="button"
|
|
1620
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1621
|
+
onClick={() => void decide("original")}
|
|
1622
|
+
>
|
|
1623
|
+
Original
|
|
1624
|
+
</button>
|
|
1625
|
+
<button
|
|
1626
|
+
type="button"
|
|
1627
|
+
className="cel-btn cel-btn--tertiary cel-btn--compact"
|
|
1628
|
+
onClick={() => void decide("no")}
|
|
1629
|
+
>
|
|
1630
|
+
Cancel
|
|
1631
|
+
</button>
|
|
1632
|
+
</div>
|
|
1633
|
+
</>
|
|
1634
|
+
) : (
|
|
1635
|
+
<>
|
|
1636
|
+
<p>Approval needed · {pending.toolName}</p>
|
|
1637
|
+
<pre className="cel-code">{approvalPreview}</pre>
|
|
1638
|
+
<div className="desk-approve-actions">
|
|
1639
|
+
<button
|
|
1640
|
+
type="button"
|
|
1641
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1642
|
+
onClick={() => void decide("yes")}
|
|
1643
|
+
>
|
|
1644
|
+
Approve
|
|
1645
|
+
</button>
|
|
1646
|
+
<button
|
|
1647
|
+
type="button"
|
|
1648
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
1649
|
+
onClick={() => void decide("no")}
|
|
1650
|
+
>
|
|
1651
|
+
Deny
|
|
1652
|
+
</button>
|
|
1653
|
+
<button
|
|
1654
|
+
type="button"
|
|
1655
|
+
className="cel-btn cel-btn--tertiary cel-btn--compact"
|
|
1656
|
+
onClick={() => void decide("always")}
|
|
1657
|
+
>
|
|
1658
|
+
Always this session
|
|
1659
|
+
</button>
|
|
1660
|
+
</div>
|
|
1661
|
+
</>
|
|
1662
|
+
)}
|
|
1569
1663
|
</section>
|
|
1570
1664
|
) : null}
|
|
1571
1665
|
|
|
@@ -2360,6 +2454,7 @@ function UserTranscriptLine(
|
|
|
2360
2454
|
}>,
|
|
2361
2455
|
): React.ReactElement {
|
|
2362
2456
|
const editing = props.editing != null;
|
|
2457
|
+
const shown = userBubbleContent(props.line.text, props.line.attachments);
|
|
2363
2458
|
return (
|
|
2364
2459
|
<article className={`desk-line desk-line--user${editing ? " is-editing" : ""}`}>
|
|
2365
2460
|
<p className="desk-line__who">
|
|
@@ -2414,8 +2509,12 @@ function UserTranscriptLine(
|
|
|
2414
2509
|
</>
|
|
2415
2510
|
) : (
|
|
2416
2511
|
<>
|
|
2417
|
-
<AttachmentThumbs items={
|
|
2418
|
-
{
|
|
2512
|
+
<AttachmentThumbs items={shown.attachments} variant="chat" />
|
|
2513
|
+
{shown.text ? (
|
|
2514
|
+
<BubbleClip text={shown.text}>
|
|
2515
|
+
<p>{shown.text}</p>
|
|
2516
|
+
</BubbleClip>
|
|
2517
|
+
) : null}
|
|
2419
2518
|
</>
|
|
2420
2519
|
)}
|
|
2421
2520
|
</div>
|
|
@@ -2434,6 +2533,7 @@ function TranscriptLine(
|
|
|
2434
2533
|
onEditCancel?: () => void;
|
|
2435
2534
|
onOpenUrl?: (url: string) => void;
|
|
2436
2535
|
onOpenFile?: (path: string, reveal: boolean) => void;
|
|
2536
|
+
integrations?: PublicIntegration[];
|
|
2437
2537
|
}>,
|
|
2438
2538
|
): React.ReactElement {
|
|
2439
2539
|
const { line, bridge, onOpenUrl, onOpenFile } = props;
|
|
@@ -2465,6 +2565,16 @@ function TranscriptLine(
|
|
|
2465
2565
|
);
|
|
2466
2566
|
}
|
|
2467
2567
|
if (line.type === "tool") {
|
|
2568
|
+
if (isPlatformTool(line.name)) {
|
|
2569
|
+
const body = formatPlatformOutput(line.output ?? "");
|
|
2570
|
+
return (
|
|
2571
|
+
<PlatformPane line={line} integrations={props.integrations ?? []}>
|
|
2572
|
+
{body ? (
|
|
2573
|
+
<RichBody text={body} bridge={bridge} onOpenUrl={onOpenUrl} onOpenFile={onOpenFile} />
|
|
2574
|
+
) : null}
|
|
2575
|
+
</PlatformPane>
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2468
2578
|
const count = eventCountSuffix(line.count);
|
|
2469
2579
|
return (
|
|
2470
2580
|
<article className={`desk-line desk-line--event is-${line.status}`}>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CaretDownIcon } from "@phosphor-icons/react/dist/csr/CaretDown";
|
|
2
|
+
import { type ReactElement, type ReactNode, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { clipLineHeight, clipNeedsExpand, collapsedClipLimit } from "./clip.ts";
|
|
4
|
+
|
|
5
|
+
export function BubbleClip(
|
|
6
|
+
props: Readonly<{
|
|
7
|
+
text: string;
|
|
8
|
+
locked?: boolean;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}>,
|
|
11
|
+
): ReactElement {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const [overflows, setOverflows] = useState(false);
|
|
14
|
+
const bodyRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
const innerRef = useRef<HTMLDivElement>(null);
|
|
16
|
+
const expanded = props.locked || open;
|
|
17
|
+
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
setOpen(false);
|
|
20
|
+
}, [props.text]);
|
|
21
|
+
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
const clip = bodyRef.current;
|
|
24
|
+
const inner = innerRef.current;
|
|
25
|
+
if (!clip || !inner || props.locked) {
|
|
26
|
+
if (props.locked) setOverflows(false);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setOverflows(
|
|
30
|
+
clipNeedsExpand(inner.scrollHeight, collapsedClipLimit(clip), clipLineHeight(inner)),
|
|
31
|
+
);
|
|
32
|
+
}, [props.locked, props.text, props.children]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
ref={bodyRef}
|
|
37
|
+
className={`desk-line__clip${expanded ? " is-open" : ""}${overflows && !props.locked ? " has-more" : ""}`}
|
|
38
|
+
>
|
|
39
|
+
<div ref={innerRef} className="desk-line__clip-inner">
|
|
40
|
+
{props.children}
|
|
41
|
+
</div>
|
|
42
|
+
{overflows && !props.locked ? (
|
|
43
|
+
<>
|
|
44
|
+
{open ? null : <div className="desk-line__fog" aria-hidden="true" />}
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
className={`desk-line__more${open ? " is-open" : ""}`}
|
|
48
|
+
aria-expanded={open}
|
|
49
|
+
aria-label={open ? "Show less" : "Show more"}
|
|
50
|
+
onClick={() => setOpen((current) => !current)}
|
|
51
|
+
>
|
|
52
|
+
<CaretDownIcon size={14} weight="bold" aria-hidden="true" />
|
|
53
|
+
</button>
|
|
54
|
+
</>
|
|
55
|
+
) : null}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -16,7 +16,7 @@ export function AttachmentThumbs(
|
|
|
16
16
|
<ul className="desk-attach-previews" aria-label="Attached files">
|
|
17
17
|
{props.items.map((item, index) => (
|
|
18
18
|
<li key={item.id ?? `${item.name}-${index}`} className="desk-attach-preview">
|
|
19
|
-
<ChatPreview name={item.name}
|
|
19
|
+
<ChatPreview name={item.name} />
|
|
20
20
|
</li>
|
|
21
21
|
))}
|
|
22
22
|
</ul>
|
|
@@ -43,31 +43,7 @@ export function AttachmentThumbs(
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
function ChatPreview(
|
|
47
|
-
props: Readonly<{
|
|
48
|
-
name: string;
|
|
49
|
-
kind: ComposerFileKind;
|
|
50
|
-
previewUrl?: string;
|
|
51
|
-
}>,
|
|
52
|
-
): React.ReactElement {
|
|
53
|
-
if (props.kind === "image" && props.previewUrl) {
|
|
54
|
-
return (
|
|
55
|
-
<>
|
|
56
|
-
<img className="desk-preview desk-preview--img" src={props.previewUrl} alt={props.name} />
|
|
57
|
-
<p className="desk-line__caption">{props.name}</p>
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
if (props.kind === "video" && props.previewUrl) {
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<video className="desk-preview desk-preview--img" controls src={props.previewUrl}>
|
|
65
|
-
<track kind="captions" srcLang="en" label="Captions" src="data:text/vtt,WEBVTT" />
|
|
66
|
-
</video>
|
|
67
|
-
<p className="desk-line__caption">{props.name}</p>
|
|
68
|
-
</>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
46
|
+
function ChatPreview(props: Readonly<{ name: string }>): React.ReactElement {
|
|
71
47
|
return (
|
|
72
48
|
<span className="desk-attach-file">
|
|
73
49
|
<FileGlyph size={16} weight="regular" aria-hidden="true" />
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { FolderSimpleIcon } from "@phosphor-icons/react/dist/csr/FolderSimple";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
|
|
4
|
+
export interface UploadItem {
|
|
5
|
+
name: string;
|
|
6
|
+
rel: string;
|
|
7
|
+
sourcePath?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function homePath(path: string): string {
|
|
11
|
+
if (path.startsWith("/Users/")) {
|
|
12
|
+
const cut = path.indexOf("/", 7);
|
|
13
|
+
if (cut > 0) return `~${path.slice(cut)}`;
|
|
14
|
+
}
|
|
15
|
+
return path;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function FilesPanel(
|
|
19
|
+
props: Readonly<{
|
|
20
|
+
items: UploadItem[];
|
|
21
|
+
onOpen: (path: string, reveal: boolean) => void;
|
|
22
|
+
}>,
|
|
23
|
+
): ReactElement {
|
|
24
|
+
return (
|
|
25
|
+
<div className="desk-integrations">
|
|
26
|
+
<p className="desk-integrations-lead">Files you attached. Copies stay in this project.</p>
|
|
27
|
+
{props.items.length === 0 ? (
|
|
28
|
+
<p className="desk-side-empty">No uploaded files</p>
|
|
29
|
+
) : (
|
|
30
|
+
<ul className="desk-integration-list">
|
|
31
|
+
{props.items.map((item) => (
|
|
32
|
+
<li key={item.rel}>
|
|
33
|
+
<span className="desk-integration-glyph desk-integration-mark" aria-hidden="true">
|
|
34
|
+
{fileGlyph(item.name)}
|
|
35
|
+
</span>
|
|
36
|
+
<div>
|
|
37
|
+
<p>{item.name}</p>
|
|
38
|
+
<em>{item.sourcePath ? homePath(item.sourcePath) : "Copy in this project"}</em>
|
|
39
|
+
</div>
|
|
40
|
+
<div className="desk-integration-actions">
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
className="cel-btn cel-btn--secondary cel-btn--compact"
|
|
44
|
+
onClick={() => props.onOpen(item.rel, false)}
|
|
45
|
+
>
|
|
46
|
+
Open
|
|
47
|
+
</button>
|
|
48
|
+
<button
|
|
49
|
+
type="button"
|
|
50
|
+
className="cel-btn cel-btn--quiet cel-btn--compact"
|
|
51
|
+
aria-label={`Show ${item.name} in folder`}
|
|
52
|
+
onClick={() => props.onOpen(item.rel, true)}
|
|
53
|
+
>
|
|
54
|
+
<FolderSimpleIcon size={16} weight="regular" />
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
</li>
|
|
58
|
+
))}
|
|
59
|
+
</ul>
|
|
60
|
+
)}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function fileGlyph(name: string): string {
|
|
66
|
+
const match = /\.([a-z0-9]{1,4})$/i.exec(name.trim());
|
|
67
|
+
return (match?.[1] ?? "file").slice(0, 4).toUpperCase();
|
|
68
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ArrowsInIcon } from "@phosphor-icons/react/dist/csr/ArrowsIn";
|
|
2
|
+
import { ArrowsOutIcon } from "@phosphor-icons/react/dist/csr/ArrowsOut";
|
|
3
|
+
import { type ReactElement, type ReactNode, useEffect, useState } from "react";
|
|
4
|
+
import type { PublicIntegration } from "./api";
|
|
5
|
+
import { BubbleClip } from "./BubbleClip";
|
|
6
|
+
import { matchPlatform, platformTitle } from "./platform";
|
|
7
|
+
import type { ToolLine } from "./thought";
|
|
8
|
+
|
|
9
|
+
export function PlatformPane(
|
|
10
|
+
props: Readonly<{
|
|
11
|
+
line: ToolLine;
|
|
12
|
+
integrations: PublicIntegration[];
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}>,
|
|
15
|
+
): ReactElement {
|
|
16
|
+
const { line, integrations } = props;
|
|
17
|
+
const match = matchPlatform(line.name, integrations);
|
|
18
|
+
const title = platformTitle(line.name, integrations);
|
|
19
|
+
const [logoFailed, setLogoFailed] = useState(false);
|
|
20
|
+
const [full, setFull] = useState(false);
|
|
21
|
+
const clipKey = line.output ?? line.error ?? line.label;
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!full) return;
|
|
25
|
+
const onKey = (event: KeyboardEvent): void => {
|
|
26
|
+
if (event.key === "Escape") setFull(false);
|
|
27
|
+
};
|
|
28
|
+
window.addEventListener("keydown", onKey);
|
|
29
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
30
|
+
}, [full]);
|
|
31
|
+
|
|
32
|
+
const pane = (
|
|
33
|
+
<article className={`desk-platform is-${line.status}${full ? " is-full" : ""}`}>
|
|
34
|
+
<header className="desk-platform__chrome">
|
|
35
|
+
<span className="desk-platform__brand">
|
|
36
|
+
{match?.logoUrl && !logoFailed ? (
|
|
37
|
+
<img
|
|
38
|
+
src={match.logoUrl}
|
|
39
|
+
alt=""
|
|
40
|
+
width={16}
|
|
41
|
+
height={16}
|
|
42
|
+
onError={() => setLogoFailed(true)}
|
|
43
|
+
/>
|
|
44
|
+
) : (
|
|
45
|
+
<span className="desk-platform__glyph">{match?.glyph ?? title.slice(0, 2)}</span>
|
|
46
|
+
)}
|
|
47
|
+
<span>{title}</span>
|
|
48
|
+
</span>
|
|
49
|
+
<span className="desk-platform__actions">
|
|
50
|
+
{line.status === "running" ? (
|
|
51
|
+
<span className="desk-platform__live">
|
|
52
|
+
<span className="desk-event__spin" aria-hidden="true" />
|
|
53
|
+
{line.label}
|
|
54
|
+
</span>
|
|
55
|
+
) : null}
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
className="desk-platform__action"
|
|
59
|
+
aria-label={full ? "Exit full screen" : "Full screen"}
|
|
60
|
+
onClick={() => setFull((current) => !current)}
|
|
61
|
+
>
|
|
62
|
+
{full ? (
|
|
63
|
+
<ArrowsInIcon size={16} weight="regular" aria-hidden="true" />
|
|
64
|
+
) : (
|
|
65
|
+
<ArrowsOutIcon size={16} weight="regular" aria-hidden="true" />
|
|
66
|
+
)}
|
|
67
|
+
</button>
|
|
68
|
+
</span>
|
|
69
|
+
</header>
|
|
70
|
+
<div className="desk-platform__body">
|
|
71
|
+
<BubbleClip text={clipKey} locked={full || line.status === "running"}>
|
|
72
|
+
{platformBody(line, props.children)}
|
|
73
|
+
</BubbleClip>
|
|
74
|
+
</div>
|
|
75
|
+
</article>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
if (!full) return pane;
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
className="desk-platform-scrim"
|
|
84
|
+
aria-label="Exit full screen"
|
|
85
|
+
onClick={() => setFull(false)}
|
|
86
|
+
/>
|
|
87
|
+
{pane}
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function platformBody(line: ToolLine, children: ReactNode): ReactNode {
|
|
93
|
+
if (line.status === "fail" && line.error) {
|
|
94
|
+
return <p className="desk-event__err">{line.error}</p>;
|
|
95
|
+
}
|
|
96
|
+
if (children) return children;
|
|
97
|
+
return <p className="desk-platform__empty">{line.label}</p>;
|
|
98
|
+
}
|
|
@@ -343,10 +343,6 @@ export function SkillsPanel(
|
|
|
343
343
|
|
|
344
344
|
return (
|
|
345
345
|
<div className="desk-integrations">
|
|
346
|
-
<p className="desk-integrations-lead">
|
|
347
|
-
Instruction files the agent reads when a task matches. Bundled skills stay off until you add
|
|
348
|
-
them. Disable a project skill to keep it out of the prompt without deleting the file.
|
|
349
|
-
</p>
|
|
350
346
|
<label className="desk-field">
|
|
351
347
|
<span className="visually-hidden">Search skills</span>
|
|
352
348
|
<input
|
|
@@ -379,9 +375,6 @@ export function SkillsPanel(
|
|
|
379
375
|
{searching ? null : (
|
|
380
376
|
<div className="desk-integration-split">
|
|
381
377
|
<p>Bundled</p>
|
|
382
|
-
<em>
|
|
383
|
-
Shipped with Caelence. Off until you add them; they do not start in the prompt.
|
|
384
|
-
</em>
|
|
385
378
|
</div>
|
|
386
379
|
)}
|
|
387
380
|
<SkillList
|
package/desktop/src/api.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface DesktopState {
|
|
|
30
30
|
skills: Array<{ name: string; source: string }>;
|
|
31
31
|
busy: boolean;
|
|
32
32
|
hasApiKey: boolean;
|
|
33
|
+
uploads?: Array<{ name: string; rel: string; sourcePath?: string }>;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export interface PickerItem {
|
|
@@ -427,7 +428,11 @@ export function deleteSession(
|
|
|
427
428
|
|
|
428
429
|
export function approve(
|
|
429
430
|
bridge: BridgeClient,
|
|
430
|
-
body: {
|
|
431
|
+
body: {
|
|
432
|
+
callId: string;
|
|
433
|
+
decision: "yes" | "no" | "always" | "copy" | "original";
|
|
434
|
+
toolName?: string;
|
|
435
|
+
},
|
|
431
436
|
): Promise<{ ok: boolean }> {
|
|
432
437
|
return request(bridge, "/approve", { method: "POST", body: JSON.stringify(body) });
|
|
433
438
|
}
|