@gemies/sdk 10.0.3 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +17 -0
- package/package.json +2 -1
- package/src/ask-lean.ts +11 -0
- package/src/components/GemieAskCore.tsx +1 -0
- package/src/components/GemieAskProviderLean.tsx +26 -0
- package/src/components/GemieAskSheet.tsx +7 -47
- package/src/components/GemieAskSheetBase.tsx +53 -0
- package/src/components/GemieAskSheetLean.tsx +10 -0
- package/src/components/GemieChatContent.tsx +32 -1
- package/src/components/GemieChatSheet.tsx +5 -0
- package/src/components/canvas/ChartRenderer.tsx +6 -3
- package/src/components/charts/chart-cards.ts +34 -0
- package/src/components/charts/default-chart-cards.ts +12 -0
- package/src/components/diff/FileChangeSection.tsx +172 -0
- package/src/components/diff/FileChangesCard.tsx +51 -0
- package/src/components/diff/FileChangesViewer.tsx +135 -0
- package/src/components/diff/PatchLines.tsx +119 -0
- package/src/components/diff/diff-renderer.ts +38 -0
- package/src/components/thread/ActionApprovalCard.tsx +95 -0
- package/src/components/thread/GemieThread.tsx +17 -0
- package/src/components/thread/ThreadRow.tsx +16 -1
- package/src/components/thread/ToolResultCard.tsx +16 -7
- package/src/index.ts +10 -0
- package/src/lib/copy-en.ts +40 -0
- package/src/lib/copy-es.ts +43 -0
- package/src/runtime/action-approvals.ts +127 -0
- package/src/runtime/config.tsx +16 -0
- package/src/runtime/index.ts +1 -0
- package/src/runtime/model.ts +1 -0
- package/src/runtime/routes.ts +5 -0
- package/src/runtime/thread/file-changes.ts +150 -0
- package/src/runtime/use-conversation-stream.ts +5 -1
- package/src/text.ts +3 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Chip } from '@oxy.so/bloom/chip';
|
|
2
|
+
import { RiFileCodeLine } from '@oxy.so/bloom/icons/RiFileCodeLine';
|
|
3
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
4
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
5
|
+
import { useMemo, useState } from 'react';
|
|
6
|
+
import { View } from 'react-native';
|
|
7
|
+
import { useLabels } from '../../lib/labels';
|
|
8
|
+
import { type CallFileChange, fileChangeTotals } from '../../runtime/thread/file-changes';
|
|
9
|
+
import { FileChangesViewer } from './FileChangesViewer';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* "3 files changed +42 −7", under a turn in which an agent edited files: a chip that opens the
|
|
13
|
+
* viewer on every file the turn changed. Nothing is drawn for a turn that changed none.
|
|
14
|
+
*/
|
|
15
|
+
export function FileChangesCard({ changes }: { changes: readonly CallFileChange[] }) {
|
|
16
|
+
const { t } = useLabels();
|
|
17
|
+
const styles = useStyles();
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const totals = useMemo(() => fileChangeTotals(changes), [changes]);
|
|
20
|
+
if (changes.length === 0) return null;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.card}>
|
|
24
|
+
<Chip
|
|
25
|
+
size="md"
|
|
26
|
+
leadingIcon={RiFileCodeLine}
|
|
27
|
+
onPress={() => setOpen(true)}
|
|
28
|
+
accessibilityLabel={t('chat.fileChanges.open', {
|
|
29
|
+
count: totals.files,
|
|
30
|
+
additions: totals.additions,
|
|
31
|
+
deletions: totals.deletions,
|
|
32
|
+
})}
|
|
33
|
+
>
|
|
34
|
+
{t('chat.fileChanges.chip', { count: totals.files })}
|
|
35
|
+
{' '}
|
|
36
|
+
<Text style={styles.added}>{`+${totals.additions}`}</Text>
|
|
37
|
+
{' '}
|
|
38
|
+
<Text style={styles.removed}>{`−${totals.deletions}`}</Text>
|
|
39
|
+
</Chip>
|
|
40
|
+
{open ? (
|
|
41
|
+
<FileChangesViewer changes={changes} open={open} onClose={() => setOpen(false)} />
|
|
42
|
+
) : null}
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const useStyles = createTokenStyles((t) => ({
|
|
48
|
+
card: { alignItems: 'flex-start', paddingVertical: 4 },
|
|
49
|
+
added: { color: t.successText, fontWeight: 600 },
|
|
50
|
+
removed: { color: t.errorText, fontWeight: 600 },
|
|
51
|
+
}));
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
2
|
+
import { Chip } from '@oxy.so/bloom/chip';
|
|
3
|
+
import { Dialog } from '@oxy.so/bloom/dialog';
|
|
4
|
+
import { RiCollapseDiagonalLine } from '@oxy.so/bloom/icons/RiCollapseDiagonalLine';
|
|
5
|
+
import { RiExpandDiagonalSLine } from '@oxy.so/bloom/icons/RiExpandDiagonalSLine';
|
|
6
|
+
import {
|
|
7
|
+
SegmentedControl,
|
|
8
|
+
SegmentedControlItem,
|
|
9
|
+
SegmentedControlItemText,
|
|
10
|
+
} from '@oxy.so/bloom/segmented-control';
|
|
11
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
12
|
+
import { useMemo, useState } from 'react';
|
|
13
|
+
import { View } from 'react-native';
|
|
14
|
+
import { useLabels } from '../../lib/labels';
|
|
15
|
+
import { type CallFileChange, fileChangeTotals } from '../../runtime/thread/file-changes';
|
|
16
|
+
import { type DiffLayout, useFileDiffRenderer } from './diff-renderer';
|
|
17
|
+
import { FileChangeSection } from './FileChangeSection';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* How many changed lines open on their own, file by file in order. A turn that changed a handful
|
|
21
|
+
* of lines opens them all; one that rewrote a project opens the first files and leaves the rest
|
|
22
|
+
* folded, so the viewer is never a wall.
|
|
23
|
+
*/
|
|
24
|
+
export const OPEN_LINE_BUDGET = 600;
|
|
25
|
+
|
|
26
|
+
/** The sections that start open: in order, until the budget of lines is spent. */
|
|
27
|
+
export function initiallyOpen(changes: readonly CallFileChange[]): Set<string> {
|
|
28
|
+
const open = new Set<string>();
|
|
29
|
+
let spent = 0;
|
|
30
|
+
for (const change of changes) {
|
|
31
|
+
const size = change.additions + change.deletions;
|
|
32
|
+
if (change.patch === undefined || change.binary || spent + size > OPEN_LINE_BUDGET) continue;
|
|
33
|
+
spent += size;
|
|
34
|
+
open.add(change.key);
|
|
35
|
+
}
|
|
36
|
+
return open;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface FileChangesViewerProps {
|
|
40
|
+
changes: readonly CallFileChange[];
|
|
41
|
+
open: boolean;
|
|
42
|
+
onClose: () => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The files an agent changed, as a sheet (a panel on a wide screen): each file a section that folds,
|
|
47
|
+
* with a unified/split choice where the host's renderer has both, line wrapping, and fold or open
|
|
48
|
+
* every file at once.
|
|
49
|
+
*/
|
|
50
|
+
export function FileChangesViewer({ changes, open, onClose }: FileChangesViewerProps) {
|
|
51
|
+
const { t } = useLabels();
|
|
52
|
+
const styles = useStyles();
|
|
53
|
+
const renderer = useFileDiffRenderer();
|
|
54
|
+
const totals = useMemo(() => fileChangeTotals(changes), [changes]);
|
|
55
|
+
const [opened, setOpened] = useState(() => initiallyOpen(changes));
|
|
56
|
+
const [layout, setLayout] = useState<DiffLayout>('unified');
|
|
57
|
+
const [wrap, setWrap] = useState(false);
|
|
58
|
+
const allOpen = changes.every((change) => opened.has(change.key));
|
|
59
|
+
const canSplit = renderer?.layouts.includes('split') === true;
|
|
60
|
+
|
|
61
|
+
const toggle = (key: string) =>
|
|
62
|
+
setOpened((current) => {
|
|
63
|
+
const next = new Set(current);
|
|
64
|
+
if (!next.delete(key)) next.add(key);
|
|
65
|
+
return next;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Dialog
|
|
70
|
+
open={open}
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
placement={{ base: 'bottom', md: 'center' }}
|
|
73
|
+
maxWidth={1040}
|
|
74
|
+
title={t('chat.fileChanges.title')}
|
|
75
|
+
description={t('chat.fileChanges.summary', {
|
|
76
|
+
count: totals.files,
|
|
77
|
+
additions: totals.additions,
|
|
78
|
+
deletions: totals.deletions,
|
|
79
|
+
})}
|
|
80
|
+
>
|
|
81
|
+
<View style={styles.toolbar}>
|
|
82
|
+
{canSplit ? (
|
|
83
|
+
<SegmentedControl
|
|
84
|
+
label={t('chat.fileChanges.layout')}
|
|
85
|
+
type="radio"
|
|
86
|
+
value={layout}
|
|
87
|
+
onValueChange={(next: string) => setLayout(next === 'split' ? 'split' : 'unified')}
|
|
88
|
+
>
|
|
89
|
+
<SegmentedControlItem value="unified">
|
|
90
|
+
<SegmentedControlItemText>{t('chat.fileChanges.unified')}</SegmentedControlItemText>
|
|
91
|
+
</SegmentedControlItem>
|
|
92
|
+
<SegmentedControlItem value="split">
|
|
93
|
+
<SegmentedControlItemText>{t('chat.fileChanges.split')}</SegmentedControlItemText>
|
|
94
|
+
</SegmentedControlItem>
|
|
95
|
+
</SegmentedControl>
|
|
96
|
+
) : null}
|
|
97
|
+
<Chip role="checkbox" size="sm" checked={wrap} onCheckedChange={setWrap}>
|
|
98
|
+
{t('chat.fileChanges.wrap')}
|
|
99
|
+
</Chip>
|
|
100
|
+
<Button
|
|
101
|
+
size="sm"
|
|
102
|
+
appearance="plain"
|
|
103
|
+
tone="neutral"
|
|
104
|
+
leadingIcon={allOpen ? RiCollapseDiagonalLine : RiExpandDiagonalSLine}
|
|
105
|
+
onPress={() => setOpened(allOpen ? new Set() : new Set(changes.map((c) => c.key)))}
|
|
106
|
+
>
|
|
107
|
+
{allOpen ? t('chat.fileChanges.collapseAll') : t('chat.fileChanges.expandAll')}
|
|
108
|
+
</Button>
|
|
109
|
+
</View>
|
|
110
|
+
<View>
|
|
111
|
+
{changes.map((change) => (
|
|
112
|
+
<FileChangeSection
|
|
113
|
+
key={change.key}
|
|
114
|
+
change={change}
|
|
115
|
+
expanded={opened.has(change.key)}
|
|
116
|
+
onToggle={() => toggle(change.key)}
|
|
117
|
+
layout={layout}
|
|
118
|
+
wrap={wrap}
|
|
119
|
+
renderer={renderer}
|
|
120
|
+
/>
|
|
121
|
+
))}
|
|
122
|
+
</View>
|
|
123
|
+
</Dialog>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const useStyles = createTokenStyles(() => ({
|
|
128
|
+
toolbar: {
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
flexWrap: 'wrap',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
gap: 8,
|
|
133
|
+
paddingBottom: 12,
|
|
134
|
+
},
|
|
135
|
+
}));
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
2
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
3
|
+
import { Text } from '@oxy.so/bloom/typography';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { Platform, ScrollView, View } from 'react-native';
|
|
6
|
+
import { useLabels } from '../../lib/labels';
|
|
7
|
+
import { type PatchLine, patchLines } from '../../runtime/thread/file-changes';
|
|
8
|
+
import type { GemiePatchViewProps } from './diff-renderer';
|
|
9
|
+
|
|
10
|
+
/** How many lines are drawn before "Show more": a patch of thousands of lines is not one frame. */
|
|
11
|
+
export const PATCH_LINES_PAGE = 400;
|
|
12
|
+
|
|
13
|
+
const MONO = Platform.select({
|
|
14
|
+
ios: 'Menlo',
|
|
15
|
+
android: 'monospace',
|
|
16
|
+
default: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/** The width, in digits, of the largest line number: every row's number column is as wide. */
|
|
20
|
+
function digitsOf(lines: readonly PatchLine[]): number {
|
|
21
|
+
let largest = 0;
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
if (line.kind === 'hunk' || line.kind === 'note') continue;
|
|
24
|
+
largest = Math.max(largest, line.oldLine ?? 0, line.newLine ?? 0);
|
|
25
|
+
}
|
|
26
|
+
return String(largest).length;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SIGN = { add: '+', delete: '−', context: ' ' } as const;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One file's patch as monospace lines, with its line numbers and the added and removed lines
|
|
33
|
+
* tinted: the SDK's own drawing of a patch, which draws on every platform and needs nothing
|
|
34
|
+
* installed. Drawn a page at a time, so a large patch costs what the person has read.
|
|
35
|
+
*/
|
|
36
|
+
export function PatchLines({ patch, wrap }: Pick<GemiePatchViewProps, 'patch' | 'wrap'>) {
|
|
37
|
+
const { t } = useLabels();
|
|
38
|
+
const styles = useStyles();
|
|
39
|
+
const lines = useMemo(() => patchLines(patch), [patch]);
|
|
40
|
+
const [shown, setShown] = useState(PATCH_LINES_PAGE);
|
|
41
|
+
const rows = lines.slice(0, shown);
|
|
42
|
+
const gutter = digitsOf(lines);
|
|
43
|
+
|
|
44
|
+
const body = (
|
|
45
|
+
<View style={wrap ? styles.wrapped : undefined}>
|
|
46
|
+
{rows.map((line, index) => (
|
|
47
|
+
// A patch's lines never reorder: their place in it is their identity.
|
|
48
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: see above
|
|
49
|
+
<Row key={`${index}:${line.kind}`} line={line} gutter={gutter} wrap={wrap} />
|
|
50
|
+
))}
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View>
|
|
56
|
+
{wrap ? body : <ScrollView horizontal>{body}</ScrollView>}
|
|
57
|
+
{lines.length > shown ? (
|
|
58
|
+
<View style={styles.more}>
|
|
59
|
+
<Button
|
|
60
|
+
size="sm"
|
|
61
|
+
appearance="outline"
|
|
62
|
+
tone="neutral"
|
|
63
|
+
onPress={() => setShown((count) => count + PATCH_LINES_PAGE)}
|
|
64
|
+
>
|
|
65
|
+
{t('chat.fileChanges.showMore', { count: lines.length - shown })}
|
|
66
|
+
</Button>
|
|
67
|
+
</View>
|
|
68
|
+
) : null}
|
|
69
|
+
</View>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function Row({ line, gutter, wrap }: { line: PatchLine; gutter: number; wrap: boolean }) {
|
|
74
|
+
const styles = useStyles();
|
|
75
|
+
if (line.kind === 'hunk' || line.kind === 'note') {
|
|
76
|
+
return (
|
|
77
|
+
<View style={styles.rowMeta}>
|
|
78
|
+
<Text style={styles.metaText}>{line.text}</Text>
|
|
79
|
+
</View>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
const number = line.kind === 'delete' ? line.oldLine : line.newLine;
|
|
83
|
+
return (
|
|
84
|
+
<View
|
|
85
|
+
style={[
|
|
86
|
+
styles.row,
|
|
87
|
+
line.kind === 'add' ? styles.added : null,
|
|
88
|
+
line.kind === 'delete' ? styles.removed : null,
|
|
89
|
+
]}
|
|
90
|
+
>
|
|
91
|
+
<Text style={[styles.number, { minWidth: gutter * 9 + 12 }]}>{number ?? ''}</Text>
|
|
92
|
+
<Text style={styles.sign}>{SIGN[line.kind]}</Text>
|
|
93
|
+
<Text style={[styles.code, wrap ? styles.codeWrapped : null]} selectable>
|
|
94
|
+
{line.text === '' ? ' ' : line.text}
|
|
95
|
+
</Text>
|
|
96
|
+
</View>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const useStyles = createTokenStyles((t) => ({
|
|
101
|
+
wrapped: { alignSelf: 'stretch' },
|
|
102
|
+
row: { flexDirection: 'row', alignItems: 'flex-start', paddingRight: 12 },
|
|
103
|
+
rowMeta: { paddingHorizontal: 12, paddingVertical: 4, backgroundColor: t.muted },
|
|
104
|
+
metaText: { fontFamily: MONO, fontSize: 12, color: t.mutedForeground },
|
|
105
|
+
added: { backgroundColor: t.successSubtle },
|
|
106
|
+
removed: { backgroundColor: t.errorSubtle },
|
|
107
|
+
number: {
|
|
108
|
+
fontFamily: MONO,
|
|
109
|
+
fontSize: 12,
|
|
110
|
+
lineHeight: 18,
|
|
111
|
+
textAlign: 'right',
|
|
112
|
+
paddingHorizontal: 6,
|
|
113
|
+
color: t.mutedForeground,
|
|
114
|
+
},
|
|
115
|
+
sign: { fontFamily: MONO, fontSize: 12, lineHeight: 18, width: 14, color: t.mutedForeground },
|
|
116
|
+
code: { fontFamily: MONO, fontSize: 12, lineHeight: 18, color: t.foreground },
|
|
117
|
+
codeWrapped: { flexShrink: 1, flexGrow: 1, flexBasis: '0%' },
|
|
118
|
+
more: { alignItems: 'center', paddingVertical: 8 },
|
|
119
|
+
}));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ComponentType, createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/** How a file's changes are laid out: one column of lines, or the old and new side by side. */
|
|
4
|
+
export type DiffLayout = 'unified' | 'split';
|
|
5
|
+
|
|
6
|
+
export interface GemiePatchViewProps {
|
|
7
|
+
/** One file's unified patch (`diff --git` headers, then its hunks). */
|
|
8
|
+
patch: string;
|
|
9
|
+
/** The file's path, to pick its language by. */
|
|
10
|
+
path: string;
|
|
11
|
+
layout: DiffLayout;
|
|
12
|
+
/** Long lines wrap instead of scrolling sideways. */
|
|
13
|
+
wrap: boolean;
|
|
14
|
+
/** The theme the person reads in. */
|
|
15
|
+
appearance: 'light' | 'dark';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The drawing of one file's patch. The SDK draws every patch itself, as plain monospace lines
|
|
20
|
+
* (`PatchLines`: nothing to install, the same on every platform); a host that wants more brings
|
|
21
|
+
* its own, as the app does on the web with syntax highlighting and a split layout
|
|
22
|
+
* (`@pierre/diffs`, which the SDK does not depend on).
|
|
23
|
+
*/
|
|
24
|
+
export interface GemieFileDiffRenderer {
|
|
25
|
+
PatchView: ComponentType<GemiePatchViewProps>;
|
|
26
|
+
/** The layouts it can draw; the viewer offers a choice only when there is more than one. */
|
|
27
|
+
layouts: readonly DiffLayout[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const FileDiffRendererContext = createContext<GemieFileDiffRenderer | null>(null);
|
|
31
|
+
|
|
32
|
+
/** The host's own drawing of a patch (`fileDiffRenderer`), over the SDK's plain lines. */
|
|
33
|
+
export const GemieFileDiffRendererProvider = FileDiffRendererContext.Provider;
|
|
34
|
+
|
|
35
|
+
/** The host's renderer, `null` when it brought none. */
|
|
36
|
+
export function useFileDiffRenderer(): GemieFileDiffRenderer | null {
|
|
37
|
+
return useContext(FileDiffRendererContext);
|
|
38
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Badge } from '@oxy.so/bloom/badge';
|
|
2
|
+
import { Button } from '@oxy.so/bloom/button';
|
|
3
|
+
import { Card, CardBody } from '@oxy.so/bloom/card';
|
|
4
|
+
import { Muted, Text } from '@oxy.so/bloom/typography';
|
|
5
|
+
import { useRef, useState } from 'react';
|
|
6
|
+
import { StyleSheet, View } from 'react-native';
|
|
7
|
+
import { useLabels } from '../../lib/labels';
|
|
8
|
+
import type { ActionApproval, ConversationActionApprovals } from '../../runtime/action-approvals';
|
|
9
|
+
|
|
10
|
+
export function ActionApprovalCard({
|
|
11
|
+
entry,
|
|
12
|
+
decide,
|
|
13
|
+
}: {
|
|
14
|
+
entry: ActionApproval;
|
|
15
|
+
decide: ConversationActionApprovals['decide'];
|
|
16
|
+
}) {
|
|
17
|
+
const { t } = useLabels();
|
|
18
|
+
const inFlight = useRef(false);
|
|
19
|
+
const [sending, setSending] = useState(false);
|
|
20
|
+
const [error, setError] = useState(false);
|
|
21
|
+
const [decided, setDecided] = useState(false);
|
|
22
|
+
|
|
23
|
+
async function submit(decision: 'approve' | 'reject') {
|
|
24
|
+
if (inFlight.current || entry.status !== 'pending') return;
|
|
25
|
+
inFlight.current = true;
|
|
26
|
+
setSending(true);
|
|
27
|
+
setError(false);
|
|
28
|
+
try {
|
|
29
|
+
await decide(entry.id, decision);
|
|
30
|
+
setDecided(true);
|
|
31
|
+
} catch {
|
|
32
|
+
setError(true);
|
|
33
|
+
} finally {
|
|
34
|
+
inFlight.current = false;
|
|
35
|
+
setSending(false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Card>
|
|
41
|
+
<CardBody>
|
|
42
|
+
<View style={styles.body}>
|
|
43
|
+
<View style={styles.header}>
|
|
44
|
+
<Text variant="title-1-medium">{entry.preview.title}</Text>
|
|
45
|
+
<Badge>
|
|
46
|
+
{t(
|
|
47
|
+
entry.status === 'executed' && entry.preview.action === 'send'
|
|
48
|
+
? 'chat.actionApproval.sent'
|
|
49
|
+
: `chat.actionApproval.status.${entry.status}`,
|
|
50
|
+
)}
|
|
51
|
+
</Badge>
|
|
52
|
+
</View>
|
|
53
|
+
{entry.preview.fields.map(({ name, label, value }) => (
|
|
54
|
+
<View key={name}>
|
|
55
|
+
<Muted>{label}</Muted>
|
|
56
|
+
<Text selectable>{value}</Text>
|
|
57
|
+
</View>
|
|
58
|
+
))}
|
|
59
|
+
{entry.status === 'pending' ? (
|
|
60
|
+
<View style={styles.buttons}>
|
|
61
|
+
<Button
|
|
62
|
+
appearance="outline"
|
|
63
|
+
tone="neutral"
|
|
64
|
+
size="sm"
|
|
65
|
+
disabled={sending || decided}
|
|
66
|
+
onPress={() => void submit('reject')}
|
|
67
|
+
>
|
|
68
|
+
{t('chat.actionApproval.reject')}
|
|
69
|
+
</Button>
|
|
70
|
+
<Button
|
|
71
|
+
size="sm"
|
|
72
|
+
disabled={sending || decided}
|
|
73
|
+
onPress={() => void submit('approve')}
|
|
74
|
+
>
|
|
75
|
+
{t(
|
|
76
|
+
entry.preview.action === 'send'
|
|
77
|
+
? 'chat.actionApproval.send'
|
|
78
|
+
: 'chat.actionApproval.approve',
|
|
79
|
+
)}
|
|
80
|
+
</Button>
|
|
81
|
+
</View>
|
|
82
|
+
) : null}
|
|
83
|
+
{error ? <Muted>{t('chat.actionApproval.decisionFailed')}</Muted> : null}
|
|
84
|
+
{entry.error ? <Muted>{entry.error}</Muted> : null}
|
|
85
|
+
</View>
|
|
86
|
+
</CardBody>
|
|
87
|
+
</Card>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const styles = StyleSheet.create({
|
|
92
|
+
body: { gap: 12 },
|
|
93
|
+
header: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 8 },
|
|
94
|
+
buttons: { flexDirection: 'row', gap: 8, justifyContent: 'flex-end' },
|
|
95
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ConversationActionApprovals } from '../../runtime/action-approvals';
|
|
2
|
+
import { ActionApprovalCard } from './ActionApprovalCard';
|
|
1
3
|
import { AgentThinking } from '@oxy.so/bloom/agent-thinking';
|
|
2
4
|
import { AiChatThread, type AiChatThreadHandle } from '@oxy.so/bloom/ai-chat';
|
|
3
5
|
import { ChatDateHeader } from '@oxy.so/bloom/chat-screen';
|
|
@@ -89,6 +91,7 @@ export interface GemieThreadProps {
|
|
|
89
91
|
* turn waits (ADR 0043 §5). Drawn after the turns, where the person is looking.
|
|
90
92
|
*/
|
|
91
93
|
approvals?: ApprovalsProps;
|
|
94
|
+
actionApprovals?: ConversationActionApprovals;
|
|
92
95
|
/** The run an agent is on for this conversation: in progress, or the card it leaves. */
|
|
93
96
|
agentActivity?: AgentActivityState | null;
|
|
94
97
|
/**
|
|
@@ -145,6 +148,7 @@ export const GemieThread = memo(function GemieThread({
|
|
|
145
148
|
onStartEdit,
|
|
146
149
|
newConversationOffer,
|
|
147
150
|
approvals,
|
|
151
|
+
actionApprovals,
|
|
148
152
|
agentActivity,
|
|
149
153
|
call,
|
|
150
154
|
empty,
|
|
@@ -289,6 +293,15 @@ export const GemieThread = memo(function GemieThread({
|
|
|
289
293
|
);
|
|
290
294
|
}
|
|
291
295
|
|
|
296
|
+
const messageIds = new Set(rows.map((message) => message.id));
|
|
297
|
+
const renderApproval = (entry: ConversationActionApprovals['entries'][number]) =>
|
|
298
|
+
actionApprovals === undefined ? null : (
|
|
299
|
+
<ActionApprovalCard key={entry.id} entry={entry} decide={actionApprovals.decide} />
|
|
300
|
+
);
|
|
301
|
+
const detachedApprovals = actionApprovals?.entries.filter(
|
|
302
|
+
(entry) => entry.messageId === null || !messageIds.has(entry.messageId),
|
|
303
|
+
);
|
|
304
|
+
|
|
292
305
|
const renderRow = (message: Message, index: number) => {
|
|
293
306
|
const fromHistory = index < history.length;
|
|
294
307
|
const timing = timingOf(message.id);
|
|
@@ -321,6 +334,9 @@ export const GemieThread = memo(function GemieThread({
|
|
|
321
334
|
workStartedAt={timing.startedAt}
|
|
322
335
|
workEndedAt={timing.endedAt}
|
|
323
336
|
/>
|
|
337
|
+
{actionApprovals?.entries
|
|
338
|
+
.filter((entry) => entry.messageId === message.id)
|
|
339
|
+
.map(renderApproval)}
|
|
324
340
|
</Fragment>
|
|
325
341
|
);
|
|
326
342
|
};
|
|
@@ -374,6 +390,7 @@ export const GemieThread = memo(function GemieThread({
|
|
|
374
390
|
{rows
|
|
375
391
|
.slice(timeline.start)
|
|
376
392
|
.map((message, offset) => renderRow(message, timeline.start + offset))}
|
|
393
|
+
{detachedApprovals?.map(renderApproval)}
|
|
377
394
|
</View>
|
|
378
395
|
|
|
379
396
|
{/* Agent execution — in-progress card or completed result card. A run that failed has no
|
|
@@ -34,13 +34,20 @@ import { askedQuestions, isQuestionInvocation } from '../../lib/questions';
|
|
|
34
34
|
import { parseCatalogueTool, useToolRenderers } from '../../lib/tool-renderers';
|
|
35
35
|
import { isWebInvocation, taskListLog, webSearchLog } from '../../lib/work-log';
|
|
36
36
|
import { useGemieRuntime } from '../../runtime/config';
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
type Message,
|
|
39
|
+
cardOf,
|
|
40
|
+
formatElapsed,
|
|
41
|
+
getToolPillLabel,
|
|
42
|
+
turnFileChanges,
|
|
43
|
+
} from '../../runtime/model';
|
|
38
44
|
import type { OpenThought } from '../../hooks/useOpenThought';
|
|
39
45
|
import { PlanPreviewCard } from '../PlanPreviewCard';
|
|
40
46
|
import { AskedQuestions } from '../QuestionCard';
|
|
41
47
|
import { CanvasComponent } from '../canvas/CanvasComponent';
|
|
42
48
|
import { ReplyMarkdown } from '../ReplyMarkdown';
|
|
43
49
|
import { MessageBlockBoundary } from './MessageBlockBoundary';
|
|
50
|
+
import { FileChangesCard } from '../diff/FileChangesCard';
|
|
44
51
|
import { ToolResultCard } from './ToolResultCard';
|
|
45
52
|
import { ChatBubble } from './ChatBubble';
|
|
46
53
|
import { TurnMenu } from './TurnMenu';
|
|
@@ -323,6 +330,8 @@ function ReplyTurn({
|
|
|
323
330
|
const card = cardOf(call);
|
|
324
331
|
return card === null ? [] : [{ key: call.toolCallId || `tool-${message.id}-${index}`, card }];
|
|
325
332
|
});
|
|
333
|
+
// The files an external agent edited this turn, whose patches its edit calls carry.
|
|
334
|
+
const fileChanges = turnFileChanges(toolInvocations);
|
|
326
335
|
/** The template swaps the steps for the reply once the turn is done. */
|
|
327
336
|
const turnWorking = isLoading && isLastReply && message.isStreaming === true;
|
|
328
337
|
|
|
@@ -418,6 +427,7 @@ function ReplyTurn({
|
|
|
418
427
|
text.length > 0 ||
|
|
419
428
|
hasWorkLog ||
|
|
420
429
|
toolCards.length > 0 ||
|
|
430
|
+
fileChanges.length > 0 ||
|
|
421
431
|
rendered.length > 0 ||
|
|
422
432
|
gemieConversations.length > 0 ||
|
|
423
433
|
inlineCanvases.length > 0 ||
|
|
@@ -558,6 +568,11 @@ function ReplyTurn({
|
|
|
558
568
|
<ToolResultCard card={card} />
|
|
559
569
|
</MessageBlockBoundary>
|
|
560
570
|
))}
|
|
571
|
+
{fileChanges.length === 0 ? null : (
|
|
572
|
+
<MessageBlockBoundary>
|
|
573
|
+
<FileChangesCard changes={fileChanges} />
|
|
574
|
+
</MessageBlockBoundary>
|
|
575
|
+
)}
|
|
561
576
|
{gemieConversations.map(({ key, conversation }) => (
|
|
562
577
|
<MessageBlockBoundary key={key}>
|
|
563
578
|
<GemieConversationCard
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
} from '../../runtime/model';
|
|
16
16
|
import { useLabels } from '../../lib/labels';
|
|
17
17
|
import { useGemieRuntime } from '../../runtime/config';
|
|
18
|
+
import { type GemieChartCards, useChartCards } from '../charts/chart-cards';
|
|
18
19
|
import { AiChatMessageLine } from '@oxy.so/bloom/ai-chat';
|
|
19
20
|
import { Badge } from '@oxy.so/bloom/badge';
|
|
20
21
|
import { Card, CardBody, CardHeader } from '@oxy.so/bloom/card';
|
|
21
|
-
import { LineChartCard } from '@oxy.so/bloom/chart-cards/line';
|
|
22
22
|
import { IconCircle } from '@oxy.so/bloom/icon-circle';
|
|
23
23
|
import { RiArrowRightSLine } from '@oxy.so/bloom/icons/RiArrowRightSLine';
|
|
24
24
|
import { RiCalendarScheduleLine } from '@oxy.so/bloom/icons/RiCalendarScheduleLine';
|
|
@@ -58,7 +58,13 @@ export function ToolResultCard({ card }: { card: ToolCard }) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function PriceLineChart({
|
|
61
|
+
function PriceLineChart({
|
|
62
|
+
chart,
|
|
63
|
+
LineChartCard,
|
|
64
|
+
}: {
|
|
65
|
+
chart: PriceChart;
|
|
66
|
+
LineChartCard: GemieChartCards['LineChartCard'];
|
|
67
|
+
}) {
|
|
62
68
|
return (
|
|
63
69
|
<LineChartCard
|
|
64
70
|
title={chart.title}
|
|
@@ -99,12 +105,14 @@ function PriceInWords({ title, price, hint }: { title: string; price: string; hi
|
|
|
99
105
|
|
|
100
106
|
function MarketResult({ data }: { data: MarketCardData }) {
|
|
101
107
|
const { t, locale } = useLabels();
|
|
102
|
-
const
|
|
108
|
+
const cards = useChartCards();
|
|
109
|
+
// Without cards to draw it with, a quote says its price in words, as one with no line does.
|
|
110
|
+
const chart = cards === null ? null : marketChart(data, t, locale);
|
|
103
111
|
return (
|
|
104
112
|
<>
|
|
105
113
|
<AiChatMessageLine block>
|
|
106
|
-
{chart !== null ? (
|
|
107
|
-
<PriceLineChart chart={chart} />
|
|
114
|
+
{chart !== null && cards !== null ? (
|
|
115
|
+
<PriceLineChart chart={chart} LineChartCard={cards.LineChartCard} />
|
|
108
116
|
) : (
|
|
109
117
|
<PriceInWords
|
|
110
118
|
title={`${data.name} · ${data.symbol}`}
|
|
@@ -124,12 +132,13 @@ function MarketResult({ data }: { data: MarketCardData }) {
|
|
|
124
132
|
|
|
125
133
|
function FairCoinResult({ data }: { data: FairCoinCardData }) {
|
|
126
134
|
const { t, locale } = useLabels();
|
|
135
|
+
const cards = useChartCards();
|
|
127
136
|
const { chart, notes } = faircoinChart(data, t, locale);
|
|
128
137
|
return (
|
|
129
138
|
<>
|
|
130
139
|
<AiChatMessageLine block>
|
|
131
|
-
{chart !== null ? (
|
|
132
|
-
<PriceLineChart chart={chart} />
|
|
140
|
+
{chart !== null && cards !== null ? (
|
|
141
|
+
<PriceLineChart chart={chart} LineChartCard={cards.LineChartCard} />
|
|
133
142
|
) : (
|
|
134
143
|
<PriceInWords
|
|
135
144
|
title={`${t('faircoin.name')} · ${t('faircoin.symbol')}`}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// @gemies/sdk — the Gemies SDK
|
|
2
2
|
// Reusable chat UI, voice, and streaming components for Oxy apps
|
|
3
3
|
|
|
4
|
+
// Bloom's chart cards, the conversation's default (`components/charts/default-chart-cards`).
|
|
5
|
+
import './components/charts/default-chart-cards';
|
|
6
|
+
|
|
4
7
|
// ── Main components ──
|
|
5
8
|
export { GemieChatContent } from './components/GemieChatWithVoice';
|
|
6
9
|
export type {
|
|
@@ -27,6 +30,13 @@ export type { GemieChatParticipants, GemieLead, GemieParticipant } from './lib/p
|
|
|
27
30
|
export { ANCHORS, leadToProfile } from './lib/flights';
|
|
28
31
|
export { parseCatalogueTool, toolRendererKey } from './lib/catalogue-tool';
|
|
29
32
|
export type { GemieToolRenderers, GemieToolResult } from './lib/tool-renderers';
|
|
33
|
+
export type { GemieChartCards } from './components/charts/chart-cards';
|
|
34
|
+
export type {
|
|
35
|
+
DiffLayout,
|
|
36
|
+
GemieFileDiffRenderer,
|
|
37
|
+
GemiePatchViewProps,
|
|
38
|
+
} from './components/diff/diff-renderer';
|
|
39
|
+
export { PatchLines } from './components/diff/PatchLines';
|
|
30
40
|
export { GemieAskProvider, useAskGemie } from './components/GemieAskProvider';
|
|
31
41
|
export type {
|
|
32
42
|
GemieAsk,
|
package/src/lib/copy-en.ts
CHANGED
|
@@ -84,7 +84,47 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
|
|
|
84
84
|
'chat.dislike': 'Dislike',
|
|
85
85
|
'chat.edit': 'Edit',
|
|
86
86
|
'chat.feedbackFailed': "Your feedback couldn't be saved.",
|
|
87
|
+
'chat.fileChanges.binary': 'Binary file, no preview',
|
|
88
|
+
'chat.fileChanges.chip': { one: '1 file changed', other: '{{count}} files changed' },
|
|
89
|
+
'chat.fileChanges.collapseAll': 'Collapse all',
|
|
90
|
+
'chat.fileChanges.copyPath': 'Copy path',
|
|
91
|
+
'chat.fileChanges.expandAll': 'Expand all',
|
|
92
|
+
'chat.fileChanges.layout': 'Layout',
|
|
93
|
+
'chat.fileChanges.noContent': 'No changes to the contents',
|
|
94
|
+
'chat.fileChanges.open': {
|
|
95
|
+
one: 'Review 1 changed file, +{{additions}} −{{deletions}}',
|
|
96
|
+
other: 'Review {{count}} changed files, +{{additions}} −{{deletions}}',
|
|
97
|
+
},
|
|
98
|
+
'chat.fileChanges.operation.add': 'Added',
|
|
99
|
+
'chat.fileChanges.operation.delete': 'Deleted',
|
|
100
|
+
'chat.fileChanges.operation.rename': 'Renamed',
|
|
101
|
+
'chat.fileChanges.operation.update': 'Modified',
|
|
102
|
+
'chat.fileChanges.renamedFrom': 'Renamed from {{path}}',
|
|
103
|
+
'chat.fileChanges.showMore': { one: 'Show 1 more line', other: 'Show {{count}} more lines' },
|
|
104
|
+
'chat.fileChanges.split': 'Split',
|
|
105
|
+
'chat.fileChanges.stats': '{{additions}} lines added, {{deletions}} lines removed',
|
|
106
|
+
'chat.fileChanges.summary': {
|
|
107
|
+
one: '1 file changed, +{{additions}} −{{deletions}}',
|
|
108
|
+
other: '{{count}} files changed, +{{additions}} −{{deletions}}',
|
|
109
|
+
},
|
|
110
|
+
'chat.fileChanges.title': 'Changes',
|
|
111
|
+
'chat.fileChanges.tooLarge': 'Too large to show here',
|
|
112
|
+
'chat.fileChanges.unified': 'Unified',
|
|
113
|
+
'chat.fileChanges.unrecorded': 'The agent did not record what changed in this file',
|
|
114
|
+
'chat.fileChanges.wrap': 'Wrap lines',
|
|
87
115
|
'chat.like': 'Like',
|
|
116
|
+
'chat.actionApproval.send': 'Send',
|
|
117
|
+
'chat.actionApproval.approve': 'Approve',
|
|
118
|
+
'chat.actionApproval.reject': 'Reject',
|
|
119
|
+
'chat.actionApproval.status.pending': 'Pending approval',
|
|
120
|
+
'chat.actionApproval.status.approved': 'Approved',
|
|
121
|
+
'chat.actionApproval.status.executing': 'Sending…',
|
|
122
|
+
'chat.actionApproval.status.executed': 'Completed',
|
|
123
|
+
'chat.actionApproval.status.failed': 'Failed',
|
|
124
|
+
'chat.actionApproval.status.rejected': 'Rejected',
|
|
125
|
+
'chat.actionApproval.status.expired': 'Expired',
|
|
126
|
+
'chat.actionApproval.sent': 'Sent',
|
|
127
|
+
'chat.actionApproval.decisionFailed': 'Your decision couldn’t be saved. Try again.',
|
|
88
128
|
'chat.approval.allow': 'Allow',
|
|
89
129
|
'chat.approval.deny': 'Deny',
|
|
90
130
|
'chat.approval.resolved.allow': '%{tool}: allowed',
|