@alia.onl/sdk 15.7.0 → 19.0.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 +255 -12
- package/README.md +241 -155
- package/package.json +17 -5
- 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/csp.ts +50 -0
- package/src/hooks/useAliaActivity.ts +3 -3
- 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/useDictation.ts +2 -3
- 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/useTTS.ts +2 -3
- 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 +2 -6
- 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/character-runtime.ts +6 -4
- 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/origins.ts +15 -0
- 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-audio-engine.ts +14 -158
- package/src/lib/voice-call-request.ts +49 -0
- package/src/lib/voice-call.ts +76 -34
- package/src/lib/voice-controls-labels.ts +31 -0
- package/src/lib/voice-protocol.ts +32 -14
- package/src/lib/voice-worklets.ts +19 -0
- package/src/lib/work-log.ts +6 -6
- package/src/runtime/agents.ts +151 -0
- package/src/runtime/api.ts +123 -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 +1427 -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/worklets/voice-processors.js +152 -0
- package/src/components/AliaChatMessageList.tsx +0 -532
- package/src/components/ThinkingBlock.tsx +0 -43
- package/src/hooks/useAliaChat.ts +0 -573
- package/src/lib/api-url.ts +0 -2
- 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
package/src/lib/catalogue.ts
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The model catalogue, as the SDK consumes it (`GET /catalogue`).
|
|
3
|
-
*
|
|
4
|
-
* Alia has no models of its own: the catalogue lists the real models Oxy serves
|
|
5
|
-
* (ids `publisher/model`), and the server decides which one a request with no
|
|
6
|
-
* `model` gets (`defaultModelId`) and which ones a picker shows first
|
|
7
|
-
* (`featuredIds`). This package therefore ships NO model identifier: a caller
|
|
8
|
-
* that names no model sends no `model`, and the server answers with its default.
|
|
9
|
-
*
|
|
10
|
-
* ## Deliberately not React, and deliberately not react-query
|
|
11
|
-
*
|
|
12
|
-
* The SDK imports `@tanstack/react-query` in no module, so a consumer mounting
|
|
13
|
-
* `<AliaChatSheet>` is not required to have a `QueryClientProvider`. Resolution
|
|
14
|
-
* happens inside `send`, at the moment a request is about to name a model, and a
|
|
15
|
-
* module-level cache keeps that from becoming a fetch per message.
|
|
16
|
-
*
|
|
17
|
-
* ## Parsing does not invent
|
|
18
|
-
*
|
|
19
|
-
* An entry without an id or a name is dropped, and a response whose entries all
|
|
20
|
-
* fail to parse THROWS rather than reading as an empty catalogue: "no models"
|
|
21
|
-
* and "we could not read the models" look identical to every caller below, and
|
|
22
|
-
* one of them means "offer nothing".
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/** A reasoning effort a model accepts. */
|
|
26
|
-
export type ReasoningEffort = 'low' | 'medium' | 'high';
|
|
27
|
-
|
|
28
|
-
const REASONING_EFFORTS: readonly ReasoningEffort[] = ['low', 'medium', 'high'];
|
|
29
|
-
|
|
30
|
-
export interface CatalogueEntry {
|
|
31
|
-
/** `publisher/model`. */
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly name: string;
|
|
34
|
-
readonly publisher: { readonly id: string; readonly name: string };
|
|
35
|
-
readonly description: string | null;
|
|
36
|
-
readonly contextWindow: number | null;
|
|
37
|
-
readonly maxOutput: number | null;
|
|
38
|
-
readonly inputModalities: readonly string[];
|
|
39
|
-
readonly outputModalities: readonly string[];
|
|
40
|
-
readonly tools: boolean;
|
|
41
|
-
/** The efforts the model accepts, cheapest first. Empty: send none. */
|
|
42
|
-
readonly reasoningEfforts: readonly ReasoningEffort[];
|
|
43
|
-
readonly pricing: { readonly inputPerMTok: string; readonly outputPerMTok: string } | null;
|
|
44
|
-
readonly releasedAt: string | null;
|
|
45
|
-
readonly featured: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Catalogue {
|
|
49
|
-
readonly entries: readonly CatalogueEntry[];
|
|
50
|
-
/** What a request without `model` is answered with, or `null` if the server did not say. */
|
|
51
|
-
readonly defaultModelId: string | null;
|
|
52
|
-
/** The ids a picker shows first, in order. */
|
|
53
|
-
readonly featuredIds: readonly string[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type JsonObject = Record<string, unknown>;
|
|
57
|
-
|
|
58
|
-
function asObject(value: unknown): JsonObject | null {
|
|
59
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
60
|
-
? (value as JsonObject)
|
|
61
|
-
: null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function asText(value: unknown): string | null {
|
|
65
|
-
return typeof value === 'string' && value !== '' ? value : null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function asCount(value: unknown): number | null {
|
|
69
|
-
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function asTexts(value: unknown): string[] {
|
|
73
|
-
return Array.isArray(value)
|
|
74
|
-
? value.filter((item): item is string => typeof item === 'string')
|
|
75
|
-
: [];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function parseEntry(value: unknown): CatalogueEntry | null {
|
|
79
|
-
const raw = asObject(value);
|
|
80
|
-
if (raw === null) return null;
|
|
81
|
-
|
|
82
|
-
const id = asText(raw.id);
|
|
83
|
-
const name = asText(raw.name);
|
|
84
|
-
if (id === null || name === null) return null;
|
|
85
|
-
|
|
86
|
-
const publisher = asObject(raw.publisher);
|
|
87
|
-
const publisherId = asText(publisher?.id) ?? id.split('/')[0] ?? id;
|
|
88
|
-
const pricing = asObject(raw.pricing);
|
|
89
|
-
const input = asText(pricing?.inputPerMTok);
|
|
90
|
-
const output = asText(pricing?.outputPerMTok);
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
id,
|
|
94
|
-
name,
|
|
95
|
-
publisher: { id: publisherId, name: asText(publisher?.name) ?? publisherId },
|
|
96
|
-
description: asText(raw.description),
|
|
97
|
-
contextWindow: asCount(raw.contextWindow),
|
|
98
|
-
maxOutput: asCount(raw.maxOutput),
|
|
99
|
-
inputModalities: asTexts(raw.inputModalities),
|
|
100
|
-
outputModalities: asTexts(raw.outputModalities),
|
|
101
|
-
tools: raw.tools === true,
|
|
102
|
-
reasoningEfforts: REASONING_EFFORTS.filter((effort) =>
|
|
103
|
-
asTexts(raw.reasoningEfforts).includes(effort),
|
|
104
|
-
),
|
|
105
|
-
pricing:
|
|
106
|
-
input !== null && output !== null ? { inputPerMTok: input, outputPerMTok: output } : null,
|
|
107
|
-
releasedAt: asText(raw.releasedAt),
|
|
108
|
-
featured: raw.featured === true,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** Turn a catalogue response into a {@link Catalogue}, or throw. */
|
|
113
|
-
export function parseCatalogue(payload: unknown): Catalogue {
|
|
114
|
-
const body = asObject(payload);
|
|
115
|
-
const data = body === null ? null : body.data;
|
|
116
|
-
if (body === null || !Array.isArray(data)) {
|
|
117
|
-
throw new Error('The model catalogue response could not be read.');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const entries: CatalogueEntry[] = [];
|
|
121
|
-
for (const value of data) {
|
|
122
|
-
const entry = parseEntry(value);
|
|
123
|
-
if (entry !== null) entries.push(entry);
|
|
124
|
-
}
|
|
125
|
-
if (data.length > 0 && entries.length === 0) {
|
|
126
|
-
throw new Error('The model catalogue response could not be read.');
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
entries,
|
|
130
|
-
defaultModelId: asText(body.defaultModelId),
|
|
131
|
-
featuredIds: asTexts(body.featuredIds),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface ModelSelection {
|
|
136
|
-
/** What the caller asked for; `undefined` is "the server's default". */
|
|
137
|
-
readonly requestedId: string | undefined;
|
|
138
|
-
/** What a request should carry as `model`; `undefined` means omit it. */
|
|
139
|
-
readonly effectiveId: string | undefined;
|
|
140
|
-
/** The entry the request will be answered by, when the catalogue says. */
|
|
141
|
-
readonly entry: CatalogueEntry | null;
|
|
142
|
-
/** `replaced` when the requested identifier is not one the catalogue offers. */
|
|
143
|
-
readonly source: 'requested' | 'default' | 'replaced';
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Resolve a requested identifier against the catalogue.
|
|
148
|
-
*
|
|
149
|
-
* - **Nothing requested** → omit `model`; the server's default answers.
|
|
150
|
-
* - **No catalogue — not loaded, or the request failed — leaves the choice
|
|
151
|
-
* alone.** Replacing on missing data would change the model under the user
|
|
152
|
-
* on any slow cold start.
|
|
153
|
-
* - **An identifier the catalogue no longer lists** is not sent (it would be
|
|
154
|
-
* refused); the request omits `model` and the server's default answers.
|
|
155
|
-
*/
|
|
156
|
-
export function resolveSelection(
|
|
157
|
-
requestedId: string | null | undefined,
|
|
158
|
-
catalogue: Catalogue | undefined,
|
|
159
|
-
): ModelSelection {
|
|
160
|
-
const requested = requestedId === null || requestedId === '' ? undefined : requestedId;
|
|
161
|
-
const defaultEntry = (): CatalogueEntry | null =>
|
|
162
|
-
catalogue?.entries.find((entry) => entry.id === catalogue.defaultModelId) ?? null;
|
|
163
|
-
|
|
164
|
-
if (requested === undefined) {
|
|
165
|
-
return {
|
|
166
|
-
requestedId: undefined,
|
|
167
|
-
effectiveId: undefined,
|
|
168
|
-
entry: defaultEntry(),
|
|
169
|
-
source: 'default',
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
if (catalogue === undefined) {
|
|
173
|
-
return { requestedId: requested, effectiveId: requested, entry: null, source: 'requested' };
|
|
174
|
-
}
|
|
175
|
-
const entry = catalogue.entries.find((candidate) => candidate.id === requested);
|
|
176
|
-
if (entry !== undefined) {
|
|
177
|
-
return { requestedId: requested, effectiveId: requested, entry, source: 'requested' };
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
requestedId: requested,
|
|
181
|
-
effectiveId: undefined,
|
|
182
|
-
entry: defaultEntry(),
|
|
183
|
-
source: 'replaced',
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* The catalogue for one API base URL, fetched at most once per URL.
|
|
189
|
-
*
|
|
190
|
-
* The promise is cached rather than the result, so concurrent callers share one
|
|
191
|
-
* request. A REJECTED promise is evicted, because caching a failure would make a
|
|
192
|
-
* single cold-start network blip permanent for the life of the process.
|
|
193
|
-
*/
|
|
194
|
-
const inFlight = new Map<string, Promise<Catalogue>>();
|
|
195
|
-
|
|
196
|
-
export function fetchCatalogue(apiUrl: string, accessToken?: string): Promise<Catalogue> {
|
|
197
|
-
const cached = inFlight.get(apiUrl);
|
|
198
|
-
if (cached !== undefined) return cached;
|
|
199
|
-
|
|
200
|
-
const request = (async () => {
|
|
201
|
-
const response = await fetch(`${apiUrl}/catalogue`, {
|
|
202
|
-
headers: accessToken === undefined ? {} : { Authorization: `Bearer ${accessToken}` },
|
|
203
|
-
});
|
|
204
|
-
if (!response.ok) throw new Error(`The model catalogue request failed (${response.status}).`);
|
|
205
|
-
return parseCatalogue(await response.json());
|
|
206
|
-
})();
|
|
207
|
-
|
|
208
|
-
inFlight.set(apiUrl, request);
|
|
209
|
-
request.catch(() => inFlight.delete(apiUrl));
|
|
210
|
-
return request;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/** Drop the cache. Exported for consumers that switch API base URL or sign a different user in. */
|
|
214
|
-
export function clearCatalogueCache(): void {
|
|
215
|
-
inFlight.clear();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* The `model` a request should carry, given what the caller asked for, or
|
|
220
|
-
* `undefined` to omit it and let the server's default answer.
|
|
221
|
-
*
|
|
222
|
-
* Never throws: a catalogue that cannot be read leaves the requested identifier
|
|
223
|
-
* alone, which is the same answer as "the catalogue has not loaded yet".
|
|
224
|
-
*/
|
|
225
|
-
export async function resolveModelId(
|
|
226
|
-
apiUrl: string,
|
|
227
|
-
requestedId: string | undefined,
|
|
228
|
-
accessToken?: string,
|
|
229
|
-
): Promise<string | undefined> {
|
|
230
|
-
if (requestedId === undefined || requestedId === '') return undefined;
|
|
231
|
-
try {
|
|
232
|
-
return resolveSelection(requestedId, await fetchCatalogue(apiUrl, accessToken)).effectiveId;
|
|
233
|
-
} catch {
|
|
234
|
-
return requestedId;
|
|
235
|
-
}
|
|
236
|
-
}
|