@alia.onl/sdk 5.1.0 → 7.1.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.
@@ -1,5 +1,5 @@
1
1
  import { useState } from 'react';
2
- import { Pressable } from 'react-native';
2
+ import { Pressable, View } from 'react-native';
3
3
  import * as Haptics from 'expo-haptics';
4
4
  import Svg, { Path } from 'react-native-svg';
5
5
  import Animated, {
@@ -13,20 +13,53 @@ import Animated, {
13
13
  Easing,
14
14
  } from 'react-native-reanimated';
15
15
 
16
- export type AliaMarkState = 'idle' | 'thinking' | 'working' | 'writing';
16
+ export type IdentityMarkState = 'idle' | 'thinking' | 'working' | 'writing';
17
17
 
18
- export interface AliaMarkProps {
18
+ export interface IdentityMarkProps {
19
19
  /** Width & height in px. Default 24. */
20
20
  size?: number;
21
21
  /** Animation state — spins while thinking/working, opacity-pulses while writing, still when idle. Default 'idle'. */
22
- state?: AliaMarkState;
22
+ state?: IdentityMarkState;
23
23
  /** Layout classes for the outer box (color comes from `color`, not classes). */
24
24
  className?: string;
25
- /** Glyph fill. Defaults to the Alia brand purple — never a theme token. */
25
+ /**
26
+ * Who the mark stands for, as a colour. An agent passes its own colour and
27
+ * gets the same artwork at the same size, which is the whole of the
28
+ * difference between Alia's mark and an agent's.
29
+ *
30
+ * The default is the Alia brand purple, and that is what an agent-less
31
+ * surface gets when it passes nothing. But do not read the default as a rule:
32
+ * three of Alia's own surfaces — the sidebar logo, the chat's mark and the
33
+ * welcome message — deliberately pass `colors.primary`, so Alia's face
34
+ * follows the account's accent there and stays brand purple elsewhere
35
+ * (`welcome-intro.tsx`). That split predates this component and is not
36
+ * settled; it is written down here so the next reader picks a side knowingly
37
+ * rather than copying whichever neighbour they happened to open.
38
+ */
26
39
  color?: string;
27
- /** Called after the press flourish. The mark spins on press wherever it's used. */
40
+ /**
41
+ * Called after the press flourish, for a mark that is a control — the sidebar
42
+ * logo, which goes home.
43
+ */
28
44
  onPress?: () => void;
29
- /** Accessible name when the mark acts as a button. */
45
+ /**
46
+ * Take the tap for the flourish alone: spin, haptic, nothing else.
47
+ *
48
+ * For a mark that IS Alia standing on its own — the welcome greeting, a chat
49
+ * header — where the spin has always been the whole of what a tap does. There
50
+ * is no callback to give it, and `onPress={() => {}}` would be a lie about
51
+ * that, so this is how such a mark asks to be pressable.
52
+ *
53
+ * Sibling of `spinOnMount`, and off by default like it. Off is what lets the
54
+ * mark sit inside a row that is itself pressable — a sidebar agent entry, a
55
+ * card — without swallowing the tap meant for the row, which is the whole
56
+ * reason the press target is opt-in.
57
+ */
58
+ spinOnPress?: boolean;
59
+ /**
60
+ * Accessible name. A mark standing in for whoever is speaking is not
61
+ * decoration, so it says who; Alia's own, drawn beside her name, is.
62
+ */
30
63
  accessibilityLabel?: string;
31
64
  /** Play the one-shot spin when the mark mounts (e.g. the sidebar rail collapsing in). */
32
65
  spinOnMount?: boolean;
@@ -46,19 +79,28 @@ const GLYPH_PATH =
46
79
  'M 728 76.199219 C 659.800781 84 596.601562 133.199219 558.800781 207.199219 C 539.800781 244.601562 527.199219 292.398438 524.601562 336.398438 L 523.398438 357.800781 L 506.199219 349 C 457.398438 324.199219 413.601562 313.398438 361 313.199219 C 314.601562 313 281.800781 320 247.199219 337.199219 C 194.398438 363.601562 161 404.601562 145.800781 461.199219 C 140.199219 482.199219 139.601562 527.398438 144.601562 550.199219 C 156.199219 601.800781 182 649.199219 220.601562 689.398438 C 239.800781 709.199219 271 734.601562 287.800781 744 C 292.199219 746.601562 296 749.199219 296 749.800781 C 296 750.398438 292.398438 753 288 755.601562 C 270.800781 765.398438 240 790.601562 221 810.398438 C 137.199219 897.398438 116.601562 1013 170.199219 1095.199219 C 200.199219 1141.199219 247.601562 1171.199219 309 1183.199219 C 333.601562 1188 383.800781 1188 410.800781 1183.199219 C 444 1177.199219 474.398438 1167 505.800781 1151.199219 L 524 1142 L 524 1153.601562 C 524 1180.398438 530.800781 1218.601562 541.199219 1250 C 582.800781 1376 690 1446.800781 796.800781 1419 C 846.398438 1406 893.800781 1369.800781 926 1320 C 953.601562 1277.199219 972.199219 1218.398438 975.398438 1163.601562 L 976.601562 1142.398438 L 994.398438 1151.398438 C 1044.800781 1176.601562 1087.800781 1187 1142 1186.800781 C 1192.601562 1186.601562 1229.601562 1177.199219 1269 1154.199219 C 1289.601562 1142.199219 1319.800781 1112.398438 1331.800781 1092.398438 C 1351.398438 1059.800781 1358.398438 1033.800781 1358.601562 994 C 1358.800781 953.199219 1353.199219 929.398438 1334 888.601562 C 1310.800781 839.601562 1265.398438 789 1217.601562 759.398438 C 1210.199219 754.800781 1204 750.601562 1204 750 C 1204 749.398438 1210.199219 745.199219 1217.601562 740.601562 C 1251.398438 719.601562 1291 681.199219 1313 648 C 1348.601562 594.601562 1364.601562 537 1358.199219 484.800781 C 1347.398438 397.800781 1285.398438 335.398438 1191 316.800781 C 1164.398438 311.398438 1114.199219 311.800781 1085 317.601562 C 1054.601562 323.601562 1029.398438 332 1000.601562 346 L 976 357.800781 L 976 346.398438 C 976 290 952.800781 217.800781 919.800781 171 C 881 116.398438 829 83.601562 769.199219 76 C 751.398438 73.800781 749.398438 73.800781 728 76.199219 Z';
47
80
 
48
81
  /**
49
- * Alia brand mark — the six-lobed flower glyph as an SVG (unselectable by
50
- * nature). Effect-free reanimated: spin while thinking/using tools,
51
- * opacity-pulse while streaming text, still when idle.
82
+ * The mark that stands for whoever is speaking — the six-lobed flower glyph as
83
+ * an SVG (unselectable by nature), painted in one colour.
84
+ *
85
+ * Alia and every agent draw THIS, and nothing else: the colour is the only
86
+ * difference between them, and where a face would otherwise go it is the size
87
+ * that adapts, not a background. There is no disc, no crop and no image to fall
88
+ * back from — an agent's Oxy account carries no avatar at all, so this is the
89
+ * whole of an agent's likeness in the app.
90
+ *
91
+ * Effect-free reanimated: spin while thinking/using tools, opacity-pulse while
92
+ * streaming text, still when idle.
52
93
  */
53
- export function AliaMark({
94
+ export function IdentityMark({
54
95
  size = 24,
55
96
  state = 'idle',
56
97
  className,
57
98
  color,
58
99
  onPress,
100
+ spinOnPress = false,
59
101
  accessibilityLabel,
60
102
  spinOnMount = false,
61
- }: AliaMarkProps) {
103
+ }: IdentityMarkProps) {
62
104
  // Imperative animations via reanimated's reactive primitive (NOT a React effect):
63
105
  // on this reanimated-web setup, animations returned from mappers/styles never
64
106
  // tick, but `sharedValue.value = withRepeat(...)` does.
@@ -126,19 +168,45 @@ export function AliaMark({
126
168
  onPress?.();
127
169
  };
128
170
 
171
+ const box = { width: size, height: size, alignItems: 'center', justifyContent: 'center' } as const;
172
+ const glyph = (
173
+ <Animated.View style={animatedStyle}>
174
+ <Svg width={size} height={size} viewBox={VIEWBOX}>
175
+ <Path d={GLYPH_PATH} fill={color ?? BRAND_FILL} />
176
+ </Svg>
177
+ </Animated.View>
178
+ );
179
+
180
+ // A `Pressable` captures the touch whether or not the caller wanted one, so
181
+ // the inert mark is a plain view — a mark drawn as somebody's face inside a
182
+ // row that is itself pressable must not stop that row from opening. Asking for
183
+ // the touch is therefore explicit, and either prop asks: a callback to run, or
184
+ // the flourish for its own sake.
185
+ if (onPress === undefined && !spinOnPress) {
186
+ return (
187
+ <View
188
+ accessibilityRole="image"
189
+ accessibilityLabel={accessibilityLabel}
190
+ className={className}
191
+ style={box}
192
+ >
193
+ {glyph}
194
+ </View>
195
+ );
196
+ }
197
+
129
198
  return (
130
199
  <Pressable
131
200
  onPress={handlePress}
132
- accessibilityRole={onPress ? 'button' : 'image'}
201
+ // Pressable, but a button only when the press DOES something beyond the
202
+ // flourish. A screen reader announcing the welcome greeting's mark as a
203
+ // button would promise an action it does not have.
204
+ accessibilityRole={onPress === undefined ? 'image' : 'button'}
133
205
  accessibilityLabel={accessibilityLabel}
134
206
  className={className}
135
- style={{ width: size, height: size, alignItems: 'center', justifyContent: 'center' }}
207
+ style={box}
136
208
  >
137
- <Animated.View style={animatedStyle}>
138
- <Svg width={size} height={size} viewBox={VIEWBOX}>
139
- <Path d={GLYPH_PATH} fill={color ?? BRAND_FILL} />
140
- </Svg>
141
- </Animated.View>
209
+ {glyph}
142
210
  </Pressable>
143
211
  );
144
212
  }
@@ -22,7 +22,6 @@ const FALLBACK_DARK: typeof FALLBACK_LIGHT = {
22
22
 
23
23
  const BODY_TEXT = { fontSize: 16, lineHeight: 28 } as const;
24
24
  const HEADING_TEXT = { fontSize: 16, lineHeight: 22 } as const;
25
- const SANS_FONT = Platform.select({ ios: 'Inter', android: 'Inter', default: 'Inter, sans-serif' })!;
26
25
  const MONO_FONT = Platform.select({ ios: 'Courier', android: 'monospace', default: 'monospace' })!;
27
26
 
28
27
  function createRules(colors: AliaColors) {
@@ -178,12 +177,27 @@ function createRules(colors: AliaColors) {
178
177
  };
179
178
  }
180
179
 
181
- function createStyles(colors: AliaColors) {
180
+ function createStyles(colors: AliaColors, fontFamily: string | undefined) {
182
181
  const { text: textColor, muted, border, primary, mutedForeground } = colors;
183
182
 
184
183
  return {
185
- body: { ...BODY_TEXT, color: textColor, fontFamily: SANS_FONT },
186
- text: { ...BODY_TEXT, color: textColor, fontFamily: SANS_FONT },
184
+ // On WEB the family arrives through the cascade down to `html`, so naming
185
+ // one here would override Bloom rather than complement it.
186
+ //
187
+ // On NATIVE nothing arrives. Bloom's only app-wide mechanism is the
188
+ // `Text.defaultProps.style` mutation in its `FontLoader.native.tsx`, and
189
+ // **React 19 drops `defaultProps` under the automatic JSX runtime** that
190
+ // Expo compiles to — measured on react@19.2.3: `createElement(Foo, {})`
191
+ // yields `{style:{fontFamily}}` while `jsx(Foo, {})` yields `{}`, for
192
+ // function AND class components alike. So that mutation reaches no `<Text>`
193
+ // in any Expo consumer, and this renderer cannot inherit a face.
194
+ //
195
+ // `fontFamily` therefore comes from the caller, which is the only party
196
+ // that both knows the family and is allowed to name it: this package has no
197
+ // `@oxyhq/bloom` dependency, and react-native-markdown-display takes RN
198
+ // style objects, so there is no className path to NativeWind's token.
199
+ body: { ...BODY_TEXT, color: textColor, fontFamily },
200
+ text: { ...BODY_TEXT, color: textColor, fontFamily },
187
201
  paragraph: { marginTop: 0, marginBottom: 8 },
188
202
  strong: { fontWeight: '600' as const },
189
203
  em: { fontStyle: 'italic' as const },
@@ -236,6 +250,17 @@ function createStyles(colors: AliaColors) {
236
250
  }
237
251
 
238
252
  export interface AliaMarkdownProps {
253
+ /**
254
+ * The sans family for body text, as a SINGLE family name — RN's `fontFamily`
255
+ * takes one, not a CSS stack.
256
+ *
257
+ * Omitted, body text inherits: correct on web, where Bloom's
258
+ * `--bloom-font-sans` reaches it through the cascade. On native nothing is
259
+ * inherited (see `createStyles`), so a native caller that wants Bloom's face
260
+ * has to pass it — this package has no `@oxyhq/bloom` dependency and so
261
+ * cannot name it itself.
262
+ */
263
+ fontFamily?: string;
239
264
  content: string;
240
265
  colors?: Partial<AliaColors>;
241
266
  }
@@ -306,13 +331,13 @@ const MarkdownBlock = React.memo(function MarkdownBlock({ content, rules, styles
306
331
  return <Markdown rules={rules} style={styles}>{content}</Markdown>;
307
332
  });
308
333
 
309
- export function AliaMarkdown({ content, colors: colorOverrides }: AliaMarkdownProps) {
334
+ export function AliaMarkdown({ content, colors: colorOverrides, fontFamily }: AliaMarkdownProps) {
310
335
  const scheme = useColorScheme();
311
336
  const fallback = scheme === 'dark' ? FALLBACK_DARK : FALLBACK_LIGHT;
312
337
  const colors = { ...fallback, ...colorOverrides } as AliaColors;
313
338
 
314
339
  const customRules = useMemo(() => createRules(colors), [colors.text, colors.muted, colors.border, colors.primary, colors.mutedForeground]);
315
- const markdownStyles = useMemo(() => createStyles(colors), [colors.text, colors.muted, colors.border, colors.primary, colors.mutedForeground]);
340
+ const markdownStyles = useMemo(() => createStyles(colors, fontFamily), [colors.text, colors.muted, colors.border, colors.primary, colors.mutedForeground, fontFamily]);
316
341
  const blocks = useMemo(() => splitMarkdownBlocks(content), [content]);
317
342
 
318
343
  if (blocks.length === 1) {
@@ -6,7 +6,7 @@ import Animated, {
6
6
  withTiming,
7
7
  withSequence,
8
8
  } from "react-native-reanimated";
9
- import { AliaMark } from "./AliaMark";
9
+ import { IdentityMark } from "./IdentityMark";
10
10
 
11
11
  const thinkingPhrases = [
12
12
  "Thinking...",
@@ -84,7 +84,7 @@ export function ThinkingIndicator({ isWorking = false, statusText, color }: { is
84
84
 
85
85
  return (
86
86
  <View className="flex-row items-center gap-2 py-2">
87
- <AliaMark size={16} state={isWorking ? 'working' : 'thinking'} color={color} />
87
+ <IdentityMark size={16} state={isWorking ? 'working' : 'thinking'} color={color} />
88
88
  <View className="flex-row items-center">
89
89
  <Text className="text-base text-muted-foreground">{shownText}</Text>
90
90
  {(statusText || isTyping) && (
@@ -13,7 +13,7 @@ const buttonVariants = cva(
13
13
  destructive: "bg-destructive web:hover:opacity-90 active:opacity-90",
14
14
  outline:
15
15
  "border border-input bg-background web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent",
16
- secondary: "bg-secondary web:hover:opacity-80 active:opacity-80",
16
+ secondary: "bg-muted web:hover:opacity-80 active:opacity-80",
17
17
  ghost:
18
18
  "web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent",
19
19
  link: "web:underline-offset-4 web:hover:underline web:focus:underline ",
@@ -42,7 +42,7 @@ const buttonTextVariants = cva(
42
42
  destructive: "text-destructive-foreground",
43
43
  outline: "group-active:text-accent-foreground",
44
44
  secondary:
45
- "text-secondary-foreground group-active:text-secondary-foreground",
45
+ "text-muted-foreground group-active:text-muted-foreground",
46
46
  ghost: "group-active:text-accent-foreground",
47
47
  link: "text-primary group-active:underline",
48
48
  pill: "text-primary-foreground",
@@ -21,6 +21,7 @@ declare module "react-native" {
21
21
  }
22
22
 
23
23
  type ChatTextInputProps = React.ComponentPropsWithoutRef<typeof TextInput> & {
24
+ unstyled?: boolean;
24
25
  noFocus?: boolean;
25
26
  onEnterPress?: () => void;
26
27
  onCompletionKey?: (key: string) => boolean;
@@ -36,6 +37,7 @@ type ChatTextInputProps = React.ComponentPropsWithoutRef<typeof TextInput> & {
36
37
  const ChatTextInput = React.forwardRef<TextInput, ChatTextInputProps>(
37
38
  ({
38
39
  className,
40
+ unstyled = false,
39
41
  noFocus = false,
40
42
  onEnterPress,
41
43
  onCompletionKey,
@@ -54,6 +56,28 @@ const ChatTextInput = React.forwardRef<TextInput, ChatTextInputProps>(
54
56
  const inputRef = React.useRef<TextInput>(null);
55
57
  const wrapperRef = React.useRef<View>(null);
56
58
 
59
+ // react-native-css observes `style` by reference. Memoizing the composed
60
+ // value prevents its own state update from manufacturing another changed
61
+ // style prop and recursively re-rendering this TextInput on native.
62
+ const inputStyle = React.useMemo(() => [
63
+ style,
64
+ !fillContainer && props.multiline && !disableAutoHeight && ({
65
+ minHeight,
66
+ maxHeight,
67
+ ...(Platform.OS === 'web'
68
+ ? { overflow: 'auto' as const, fieldSizing: 'content' }
69
+ : {}),
70
+ } as TextStyle & { fieldSizing?: string }),
71
+ fillContainer && { flex: 1, height: '100%' as const },
72
+ ], [
73
+ disableAutoHeight,
74
+ fillContainer,
75
+ maxHeight,
76
+ minHeight,
77
+ props.multiline,
78
+ style,
79
+ ]);
80
+
57
81
  React.useImperativeHandle(ref, () => inputRef.current as TextInput);
58
82
 
59
83
  // Attach paste event listener (web only)
@@ -135,7 +159,8 @@ const ChatTextInput = React.forwardRef<TextInput, ChatTextInputProps>(
135
159
  <TextInput
136
160
  ref={inputRef}
137
161
  className={cn(
138
- "native:text-md native:leading-[1.25] rounded-xl border border-input bg-background px-3.5 text-base text-foreground file:border-0 file:bg-transparent file:font-medium placeholder:text-muted-foreground web:flex web:w-full web:py-2 lg:text-sm",
162
+ "native:text-md native:leading-[1.25] text-base text-foreground file:border-0 file:bg-transparent file:font-medium placeholder:text-muted-foreground web:flex web:w-full web:py-2 lg:text-sm",
163
+ !unstyled && "rounded-xl border border-input bg-background px-3.5",
139
164
  "web:ring-offset-background web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2",
140
165
  !fillContainer && !props.multiline && "h-9",
141
166
  fillContainer && "h-full",
@@ -147,16 +172,7 @@ const ChatTextInput = React.forwardRef<TextInput, ChatTextInputProps>(
147
172
  onKeyPress={handleKeyPress}
148
173
  onContentSizeChange={handleContentSizeChange}
149
174
  scrollEnabled={fillContainer || props.multiline}
150
- style={[
151
- style,
152
- !fillContainer && props.multiline && !disableAutoHeight && ({
153
- minHeight,
154
- maxHeight,
155
- overflow: 'auto',
156
- ...(Platform.OS === 'web' ? { fieldSizing: 'content' } : {}),
157
- } as TextStyle & { overflow: 'auto'; fieldSizing?: string }),
158
- fillContainer && { flex: 1, height: '100%' },
159
- ]}
175
+ style={inputStyle}
160
176
  {...props}
161
177
  />
162
178
  </View>
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { View } from "react-native";
2
+ import { StyleSheet, View } from "react-native";
3
3
  import { cn } from "../../../lib/utils";
4
4
  import { ChatTextInput } from "../chat-text-input";
5
5
  import { usePromptInput } from "./context";
@@ -28,6 +28,11 @@ export function PromptInputTextarea({
28
28
  handleCompletionKey,
29
29
  } = usePromptInput();
30
30
 
31
+ const inputStyle = React.useMemo(
32
+ () => [style, styles.borderless, isFullscreen && styles.fullscreen],
33
+ [isFullscreen, style],
34
+ );
35
+
31
36
  const textInput = (
32
37
  <ChatTextInput
33
38
  ref={textareaRef}
@@ -42,12 +47,14 @@ export function PromptInputTextarea({
42
47
  maxHeight={isFullscreen ? 10000 : maxHeight}
43
48
  onImagePaste={onImagePaste}
44
49
  fillContainer={isFullscreen}
50
+ unstyled
45
51
  className={cn(
46
- "w-full border-0 bg-transparent text-foreground shadow-none",
52
+ "w-full border-0 bg-transparent text-foreground web:shadow-none",
47
53
  isFullscreen ? "px-4 pt-4" : "min-h-[44px] py-3",
48
54
  className
49
55
  )}
50
- style={[style, isFullscreen && { paddingBottom: 100 }]}
56
+ style={inputStyle}
57
+ underlineColorAndroid="transparent"
51
58
  placeholder={placeholder}
52
59
  multiline
53
60
  editable={!disabled}
@@ -62,3 +69,12 @@ export function PromptInputTextarea({
62
69
 
63
70
  return textInput;
64
71
  }
72
+
73
+ const styles = StyleSheet.create({
74
+ borderless: {
75
+ borderWidth: 0,
76
+ },
77
+ fullscreen: {
78
+ paddingBottom: 100,
79
+ },
80
+ });