@alia.onl/sdk 15.8.0 → 19.1.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 +262 -13
- package/README.md +223 -151
- package/package.json +16 -6
- package/src/animations.ts +0 -1
- package/src/components/AliaAskProvider.tsx +127 -0
- package/src/components/AliaChatContent.tsx +604 -392
- package/src/components/AliaChatHeader.tsx +14 -38
- package/src/components/AliaChatScreen.tsx +56 -31
- package/src/components/AliaChatSheet.tsx +110 -36
- package/src/components/AliaComposer.tsx +1 -1
- package/src/components/AliaParticipants.tsx +202 -0
- package/src/components/AliaParticipantsHeader.tsx +60 -0
- package/src/components/AliaSharedConversation.tsx +86 -0
- package/src/components/AliaWelcomeMessage.tsx +18 -5
- package/src/components/Image.tsx +12 -0
- package/src/components/Markdown.tsx +498 -14
- package/src/components/PlanPreviewCard.tsx +7 -49
- package/src/components/ReplyMarkdown.tsx +359 -0
- package/src/components/RichBlocks.tsx +195 -0
- package/src/components/canvas/CanvasComponent.tsx +59 -0
- package/src/components/canvas/ChartRenderer.tsx +73 -0
- package/src/components/canvas/CodeRenderer.tsx +24 -0
- package/src/components/canvas/FormRenderer.tsx +101 -0
- package/src/components/canvas/MarkdownRenderer.tsx +14 -0
- package/src/components/canvas/TableRenderer.tsx +47 -0
- package/src/components/thought/FilesAndSources.tsx +120 -0
- package/src/components/thought/ThoughtPanel.tsx +417 -0
- package/src/components/thought/ToolStep.tsx +141 -0
- package/src/components/thread/AgentResultCard.tsx +125 -0
- package/src/components/thread/AgentTaskCard.tsx +127 -0
- package/src/components/thread/AliaThread.tsx +401 -0
- package/src/components/thread/MessageBlockBoundary.tsx +78 -0
- package/src/components/thread/NewConversationOffer.tsx +54 -0
- package/src/components/thread/ThreadRow.tsx +458 -0
- package/src/components/thread/ThreadSearch.tsx +129 -0
- package/src/components/thread/ToolResultCard.tsx +254 -0
- package/src/components/thread/TurnMenu.tsx +54 -0
- package/src/components/thread/TurnStatusLine.tsx +34 -0
- package/src/components/voice/AliaVoiceCall.tsx +21 -0
- package/src/components/voice/VoiceControls.tsx +2 -28
- package/src/components/voice/VoiceSession.tsx +39 -11
- package/src/hooks/useAliaActivity.ts +2 -2
- package/src/hooks/useAtBottom.ts +51 -0
- package/src/hooks/useAttachMenu.ts +94 -0
- package/src/hooks/useChatComposer.ts +299 -0
- package/src/hooks/useChatVoice.ts +129 -0
- package/src/hooks/useDocumentPicker.ts +3 -29
- package/src/hooks/useFailedTurnToast.ts +43 -0
- package/src/hooks/useMessageVote.ts +50 -0
- package/src/hooks/useOpenThought.ts +79 -0
- package/src/hooks/usePendingQuestions.ts +2 -2
- package/src/hooks/useReadAloud.ts +92 -0
- package/src/hooks/useShareHandler.ts +24 -0
- package/src/hooks/useSoundEffects.ts +1 -1
- package/src/hooks/useThoughtScope.ts +59 -0
- package/src/hooks/useThreadRows.ts +145 -0
- package/src/hooks/useThreadView.ts +68 -0
- package/src/hooks/useTimelineWindow.ts +256 -0
- package/src/hooks/useVoiceLauncher.ts +180 -0
- package/src/hooks/useVoiceRoom.ts +4 -4
- package/src/index.ts +43 -29
- package/src/lib/activity-store.ts +1 -1
- package/src/lib/add-menu.ts +7 -0
- package/src/lib/call-thread.ts +33 -0
- package/src/lib/citations.ts +79 -2
- package/src/lib/clipboard.ts +23 -0
- package/src/lib/content-utils.ts +10 -0
- package/src/lib/copy-en.ts +284 -0
- package/src/lib/copy.ts +32 -0
- package/src/lib/document-picker.ts +31 -0
- package/src/lib/flights.ts +22 -13
- package/src/lib/focus-return.ts +66 -0
- package/src/lib/keyboard.native.tsx +19 -0
- package/src/lib/keyboard.tsx +9 -0
- package/src/lib/labels.tsx +69 -17
- package/src/lib/participants.ts +86 -0
- package/src/lib/power-level-options.ts +66 -0
- package/src/lib/questions.ts +2 -2
- package/src/lib/task-labels.ts +4 -4
- package/src/lib/tool-call-status.ts +1 -1
- package/src/lib/tool-icons.ts +36 -0
- package/src/lib/tool-renderers.tsx +48 -0
- package/src/lib/turn-state.ts +2 -2
- package/src/lib/voice-call-request.ts +49 -0
- package/src/lib/voice-call.ts +98 -35
- package/src/lib/voice-controls-labels.ts +31 -0
- package/src/lib/voice-protocol.ts +34 -15
- package/src/lib/work-log.ts +6 -6
- package/src/runtime/agents.ts +151 -0
- package/src/runtime/api.ts +141 -0
- package/src/runtime/app-assertion.ts +53 -0
- package/src/runtime/attachment-utils.ts +96 -0
- package/src/runtime/composer-draft-store.ts +270 -0
- package/src/runtime/config.tsx +186 -0
- package/src/runtime/conversation-store.ts +49 -0
- package/src/runtime/conversations.ts +557 -0
- package/src/runtime/error-utils.ts +104 -0
- package/src/runtime/host-tools.ts +140 -0
- package/src/runtime/index.ts +113 -0
- package/src/runtime/message-history.ts +124 -0
- package/src/runtime/model.ts +39 -0
- package/src/runtime/oxy-files.ts +37 -0
- package/src/runtime/power-levels.ts +66 -0
- package/src/runtime/query-keys.ts +34 -0
- package/src/runtime/random-uuid.ts +25 -0
- package/src/runtime/routes.ts +51 -0
- package/src/runtime/sharing.ts +165 -0
- package/src/runtime/sse-frame-reader.ts +88 -0
- package/src/runtime/stream-events.ts +146 -0
- package/src/runtime/stream-outcome.ts +21 -0
- package/src/runtime/thought-store.ts +103 -0
- package/src/runtime/thread/agent-activity.ts +261 -0
- package/src/runtime/thread/automation-labels.ts +79 -0
- package/src/runtime/thread/conversation-export.ts +135 -0
- package/src/runtime/thread/message-days.ts +120 -0
- package/src/runtime/thread/message-processor.ts +93 -0
- package/src/runtime/thread/task-utils.ts +11 -0
- package/src/runtime/thread/thought-utils.ts +752 -0
- package/src/runtime/thread/thread-history.ts +139 -0
- package/src/runtime/thread/timeline.ts +202 -0
- package/src/runtime/thread/title-tags.ts +8 -0
- package/src/runtime/thread/tool-cards.ts +383 -0
- package/src/runtime/turn-failure.ts +108 -0
- package/src/runtime/types.ts +148 -0
- package/src/runtime/usage-limit-error.ts +44 -0
- package/src/runtime/use-agent-activity.ts +80 -0
- package/src/runtime/use-conversation-stream.ts +1433 -0
- package/src/runtime/use-conversation-thread.ts +556 -0
- package/src/runtime/use-start-conversation.ts +107 -0
- package/src/runtime/use-thread-history.ts +64 -0
- package/src/runtime/use-thread-search.ts +95 -0
- package/src/runtime/use-turn-edit.ts +99 -0
- package/src/tools.ts +2 -2
- package/src/types.ts +18 -47
- package/src/components/AliaChatMessageList.tsx +0 -532
- package/src/components/ThinkingBlock.tsx +0 -43
- package/src/hooks/useAliaChat.ts +0 -573
- package/src/lib/catalogue.ts +0 -236
- package/src/lib/chat-stream.ts +0 -655
- package/src/lib/chat-transport.ts +0 -98
- package/src/lib/delegation.ts +0 -34
- package/src/lib/work-log-copy.ts +0 -61
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Ask Alia", "Ask Sindi": one sheet an app mounts once, opened on any agent from anywhere in it.
|
|
3
|
+
*
|
|
4
|
+
* The app names the agents it offers (`agents`, by a key of its own) and configures the sheet
|
|
5
|
+
* once — its host tools, renderers, words, voice, context, upsell and share. A button calls
|
|
6
|
+
* `useAskAgent().ask(key, turn)`. Signed out, the sheet is not mounted (it could not call Alia):
|
|
7
|
+
* `ask` opens Oxy's sign-in instead, and the person asks again once signed in.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useAuth } from '@oxy.so/services/ui/client';
|
|
11
|
+
import {
|
|
12
|
+
createContext,
|
|
13
|
+
type ReactNode,
|
|
14
|
+
useCallback,
|
|
15
|
+
useContext,
|
|
16
|
+
useEffect,
|
|
17
|
+
useMemo,
|
|
18
|
+
useRef,
|
|
19
|
+
useState,
|
|
20
|
+
} from 'react';
|
|
21
|
+
import type { AliaTurn } from '../hooks/useChatComposer';
|
|
22
|
+
import { AliaChatSheet, type AliaChatSheetProps, type AliaChatSheetRef } from './AliaChatSheet';
|
|
23
|
+
|
|
24
|
+
/** The agents an app offers, by its own key. An entry without `id` is Alia. */
|
|
25
|
+
export type AliaAskAgents = Readonly<Record<string, { id?: string }>>;
|
|
26
|
+
|
|
27
|
+
export interface AliaAskProviderProps
|
|
28
|
+
extends Pick<
|
|
29
|
+
AliaChatSheetProps,
|
|
30
|
+
| 'hostTools'
|
|
31
|
+
| 'toolRenderers'
|
|
32
|
+
| 'labels'
|
|
33
|
+
| 'voice'
|
|
34
|
+
| 'clientContext'
|
|
35
|
+
| 'onFeatureLocked'
|
|
36
|
+
| 'onShare'
|
|
37
|
+
| 'model'
|
|
38
|
+
| 'apiUrl'
|
|
39
|
+
| 'characterRuntimeUrl'
|
|
40
|
+
| 'headerMenu'
|
|
41
|
+
> {
|
|
42
|
+
/** The agents `ask` opens, by key. Omitted, the sheet only ever opens on Alia. */
|
|
43
|
+
agents?: AliaAskAgents;
|
|
44
|
+
/** The lines offered over Alia's empty composer; an agent offers its own starters. */
|
|
45
|
+
welcomeSuggestions?: AliaChatSheetProps['welcomeSuggestions'];
|
|
46
|
+
children: ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AliaAsk {
|
|
50
|
+
/**
|
|
51
|
+
* Open the sheet on the agent `agentKey` (omitted, Alia), with `turn` already sent when given
|
|
52
|
+
* ("ask Sindi about this listing"). Signed out, opens Oxy's sign-in instead.
|
|
53
|
+
*/
|
|
54
|
+
ask: (agentKey?: string, turn?: AliaTurn) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const AskContext = createContext<AliaAsk | null>(null);
|
|
58
|
+
|
|
59
|
+
/** The app's way to open its one Alia sheet. Must be used under `AliaAskProvider`. */
|
|
60
|
+
export function useAskAgent(): AliaAsk {
|
|
61
|
+
const ask = useContext(AskContext);
|
|
62
|
+
if (ask === null) throw new Error('useAskAgent must be used within an AliaAskProvider');
|
|
63
|
+
return ask;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Which agent the sheet is on, and the opening that waits for that sheet to mount. */
|
|
67
|
+
interface Opening {
|
|
68
|
+
key: string | undefined;
|
|
69
|
+
turn: AliaTurn | undefined;
|
|
70
|
+
/** Changes on every `ask`, so asking the same agent twice opens twice. */
|
|
71
|
+
serial: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function AliaAskProvider({
|
|
75
|
+
agents,
|
|
76
|
+
welcomeSuggestions,
|
|
77
|
+
children,
|
|
78
|
+
...sheet
|
|
79
|
+
}: AliaAskProviderProps) {
|
|
80
|
+
const { canUsePrivateApi, signIn } = useAuth();
|
|
81
|
+
const sheetRef = useRef<AliaChatSheetRef>(null);
|
|
82
|
+
const [opening, setOpening] = useState<Opening | null>(null);
|
|
83
|
+
const [current, setCurrent] = useState<string | undefined>(undefined);
|
|
84
|
+
const agentsRef = useRef(agents);
|
|
85
|
+
agentsRef.current = agents;
|
|
86
|
+
|
|
87
|
+
const ask = useCallback(
|
|
88
|
+
(agentKey?: string, turn?: AliaTurn) => {
|
|
89
|
+
if (agentKey !== undefined && agentsRef.current?.[agentKey] === undefined) {
|
|
90
|
+
throw new Error(`AliaAskProvider has no agent "${agentKey}"`);
|
|
91
|
+
}
|
|
92
|
+
if (!canUsePrivateApi) {
|
|
93
|
+
void signIn().catch(() => undefined);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setCurrent(agentKey);
|
|
97
|
+
setOpening((previous) => ({ key: agentKey, turn, serial: (previous?.serial ?? 0) + 1 }));
|
|
98
|
+
},
|
|
99
|
+
[canUsePrivateApi, signIn],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Presented once the sheet for that agent is the one mounted (a different agent is a new sheet).
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (opening === null || opening.key !== current) return;
|
|
105
|
+
sheetRef.current?.present(opening.turn);
|
|
106
|
+
setOpening(null);
|
|
107
|
+
}, [opening, current]);
|
|
108
|
+
|
|
109
|
+
const agentId = current === undefined ? undefined : agents?.[current]?.id;
|
|
110
|
+
const agent = useMemo(() => (agentId === undefined ? undefined : { id: agentId }), [agentId]);
|
|
111
|
+
const value = useMemo<AliaAsk>(() => ({ ask }), [ask]);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<AskContext.Provider value={value}>
|
|
115
|
+
{children}
|
|
116
|
+
{canUsePrivateApi ? (
|
|
117
|
+
<AliaChatSheet
|
|
118
|
+
key={agentId ?? 'alia'}
|
|
119
|
+
ref={sheetRef}
|
|
120
|
+
{...sheet}
|
|
121
|
+
agent={agent}
|
|
122
|
+
welcomeSuggestions={agent === undefined ? welcomeSuggestions : undefined}
|
|
123
|
+
/>
|
|
124
|
+
) : null}
|
|
125
|
+
</AskContext.Provider>
|
|
126
|
+
);
|
|
127
|
+
}
|