deepspace 0.2.5 → 0.2.7
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/dist/index.d.ts +80 -1
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -1
- package/dist/worker.d.ts +188 -10
- package/dist/worker.js +459 -12
- package/dist/worker.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -6773,6 +6773,85 @@ declare const integration: {
|
|
|
6773
6773
|
delete<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<IntegrationResponse<T>>;
|
|
6774
6774
|
};
|
|
6775
6775
|
|
|
6776
|
+
/**
|
|
6777
|
+
* Pure decoders for the Vercel AI SDK v5 `toUIMessageStreamResponse` body.
|
|
6778
|
+
*
|
|
6779
|
+
* The wire format is SSE: each event is `data: <json>\n\n`, terminated by
|
|
6780
|
+
* `data: [DONE]\n\n`. Each event carries a `type` discriminator
|
|
6781
|
+
* (`text-delta`, `tool-input-available`, `tool-output-available`,
|
|
6782
|
+
* `tool-input-error`, `tool-output-error`, `error`, `abort`, …) — see the
|
|
6783
|
+
* `UIMessageChunk` union in `ai/dist/index.d.ts`.
|
|
6784
|
+
*
|
|
6785
|
+
* This module decodes those chunks into a small action vocabulary that
|
|
6786
|
+
* the React layer then applies to its state. Keeping decode pure means
|
|
6787
|
+
* the v5-boundary behavior is fully testable without spinning up a
|
|
6788
|
+
* component tree.
|
|
6789
|
+
*/
|
|
6790
|
+
/** Raw v5 stream chunk, as parsed off the wire. `type` may be any string. */
|
|
6791
|
+
type AiStreamChunk = Record<string, unknown> & {
|
|
6792
|
+
type?: unknown;
|
|
6793
|
+
};
|
|
6794
|
+
/**
|
|
6795
|
+
* Strip one SSE line's framing. Returns the parsed JSON payload, or `null`
|
|
6796
|
+
* for blank lines, comment lines (`:` prefix), non-`data:` SSE fields, the
|
|
6797
|
+
* `[DONE]` terminator, or any line whose payload doesn't parse as JSON.
|
|
6798
|
+
*
|
|
6799
|
+
* Multi-line `data:` events (per the SSE spec, joined by `\n` before
|
|
6800
|
+
* dispatch) are NOT supported — v5's emitter never produces them. If you
|
|
6801
|
+
* hit a wire intermediary that re-splits long payloads (e.g. a proxy that
|
|
6802
|
+
* caps line length), upgrade this to accumulate consecutive `data:` lines
|
|
6803
|
+
* until a blank line.
|
|
6804
|
+
*/
|
|
6805
|
+
declare function parseSseLine(line: string): AiStreamChunk | null;
|
|
6806
|
+
/**
|
|
6807
|
+
* Action vocabulary the React layer applies. Every `decodeAiStreamChunk`
|
|
6808
|
+
* output is one of these — `null` means the chunk is intentionally ignored
|
|
6809
|
+
* (lifecycle markers, reasoning we don't surface yet, etc.).
|
|
6810
|
+
*
|
|
6811
|
+
* Wire field renames (v5): chunks carry `input` / `output` directly. We
|
|
6812
|
+
* map them to `args` / `result` here so persisted UI shapes stay v4-stable.
|
|
6813
|
+
*/
|
|
6814
|
+
type AiStreamAction = {
|
|
6815
|
+
type: 'append-text';
|
|
6816
|
+
delta: string;
|
|
6817
|
+
} | {
|
|
6818
|
+
type: 'upsert-tool-call';
|
|
6819
|
+
toolCallId: string;
|
|
6820
|
+
toolName: string;
|
|
6821
|
+
input: unknown;
|
|
6822
|
+
} | {
|
|
6823
|
+
type: 'finalize-tool-call';
|
|
6824
|
+
toolCallId: string;
|
|
6825
|
+
result: unknown;
|
|
6826
|
+
}
|
|
6827
|
+
/**
|
|
6828
|
+
* Schema validation rejected the input before the tool ran; no preceding
|
|
6829
|
+
* `upsert-tool-call` was emitted, so the React layer must create the
|
|
6830
|
+
* invocation and finalize it as failed in one step.
|
|
6831
|
+
*/
|
|
6832
|
+
| {
|
|
6833
|
+
type: 'fail-tool-input';
|
|
6834
|
+
toolCallId: string;
|
|
6835
|
+
toolName: string;
|
|
6836
|
+
input: unknown;
|
|
6837
|
+
errorText: string;
|
|
6838
|
+
}
|
|
6839
|
+
/** Tool execution failed; a previous `upsert-tool-call` exists to finalize. */
|
|
6840
|
+
| {
|
|
6841
|
+
type: 'fail-tool-output';
|
|
6842
|
+
toolCallId: string;
|
|
6843
|
+
errorText: string;
|
|
6844
|
+
} | {
|
|
6845
|
+
type: 'stream-error';
|
|
6846
|
+
errorText: string;
|
|
6847
|
+
}
|
|
6848
|
+
/** Server-side abort with no error chunk to follow. */
|
|
6849
|
+
| {
|
|
6850
|
+
type: 'abort';
|
|
6851
|
+
};
|
|
6852
|
+
/** Decode one v5 UIMessage stream chunk into an action, or `null` to ignore. */
|
|
6853
|
+
declare function decodeAiStreamChunk(chunk: AiStreamChunk): AiStreamAction | null;
|
|
6854
|
+
|
|
6776
6855
|
declare function cn(...inputs: ClassValue[]): string;
|
|
6777
6856
|
|
|
6778
6857
|
declare const Card: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
@@ -7145,4 +7224,4 @@ interface SearchInputProps extends Omit<React$1.ComponentProps<'input'>, 'type'>
|
|
|
7145
7224
|
}
|
|
7146
7225
|
declare const SearchInput: React$1.ForwardRefExoticComponent<Omit<SearchInputProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
7147
7226
|
|
|
7148
|
-
export { Alert, AlertDescription, AlertTitle, AuthGate, type AuthGateProps, AuthOverlay, Avatar, AvatarFallback, AvatarImage, Awareness, type AwarenessState, type AwarenessStates, Badge, type BadgeProps, type BaseMessage, Button, type ButtonProps, type CanvasShapeClient, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardTitle, type Channel, type ChannelInvitation, type ChannelMember, Checkbox, type ClientMessage, type CollectionSchema, ConfirmModal, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ENV, EmptyDocuments, EmptyError, EmptyItems, EmptyProjects, EmptySearch, EmptyState, EmptyTeam, type Environment, type FetchUserProfile, type FileAttachment, type GamePlayer, GridCard, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, Input, type IntegrationResponse, Label, type LinkPreviewData, LoadingOverlay, LoadingSpinner, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, Modal, type MsgType, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, Progress, type ProtocolMessage, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type ServerMessage, SignedIn, SignedOut, Skeleton, SkeletonAvatar, SkeletonCard, SkeletonList, SkeletonTable, SkeletonText, Switch, type SyncResult, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCanvasResult, type UseCronMonitorResult, type UseGameRoomResult, type UsePresenceRoomResult, type UseR2FilesReturn, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, applyDeepSpaceTheme, applyUIThemeTokens, authClient, badgeVariants, buttonVariants, clearAuthToken, clearDeepSpaceTheme, clientBuild, cn, createDecoder, createEncoder, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getEnvironmentConfig, getMessageType, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, parseMessageMetadata, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, serverBuild, shouldGroupMessages, signIn, signOut, toConnectionStatus, toUint8Array, useAuth, useAuthUser, useCanvas, useChannelMembers, useChannels, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useGameRoom, useInbox, useIsDarkTheme, useMessages, useMutations, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useToast, useUser, useUserLookup, useUsers, useYjsField, useYjsRoom, useYjsText, writeVarUint, writeVarUint8Array };
|
|
7227
|
+
export { type AiStreamAction, type AiStreamChunk, Alert, AlertDescription, AlertTitle, AuthGate, type AuthGateProps, AuthOverlay, Avatar, AvatarFallback, AvatarImage, Awareness, type AwarenessState, type AwarenessStates, Badge, type BadgeProps, type BaseMessage, Button, type ButtonProps, type CanvasShapeClient, Card, CardContent, CardDescription, CardFooter, CardGrid, CardHeader, CardTitle, type Channel, type ChannelInvitation, type ChannelMember, Checkbox, type ClientMessage, type CollectionSchema, ConfirmModal, type ConnectionAttachment, type ConnectionStatus, type ContentSegment, type ConversationObject, type CronHistoryEntry, type CronTaskState, DEEPSPACE_THEME_PROPERTIES, DEFAULT_USER_COLORS, DeepSpaceAuthProvider, type DeepSpaceThemeConfig, DeepSpaceThemeProvider, type DeepSpaceThemeProviderProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ENV, EmptyDocuments, EmptyError, EmptyItems, EmptyProjects, EmptySearch, EmptyState, EmptyTeam, type Environment, type FetchUserProfile, type FileAttachment, type GamePlayer, GridCard, type GroupedReaction, GuestBanner, type HandlerContext, type InboxEntry, Input, type IntegrationResponse, Label, type LinkPreviewData, LoadingOverlay, LoadingSpinner, MSG, MSG_AWARENESS, MSG_SYNC, MSG_SYNC_STEP1, MSG_SYNC_STEP2, MSG_SYNC_UPDATE, MSG_YJS_AWARENESS, MSG_YJS_SYNC, type MemberRecord, type Message, type MessageHandlers, type MessageRecord, Modal, type MsgType, PlatformContext, type PlatformContextValue, PlatformProvider, type PlatformWSOptions, type PlatformWSResult, type PresencePeerClient, Progress, type ProtocolMessage, type Query, type R2FileInfo, type R2Scope, type R2UploadResult, ROLES, ROLE_ADMIN, ROLE_ANONYMOUS, ROLE_CONFIG, ROLE_DEFAULT, type Reaction, type ReactionRecord, type ReadCursorRecord, type ReadReceipt, type RecordData, RecordProvider, type RecordProviderProps, RecordScope, type RequestOptions, type Role, type RoomUser, type ScopeEntry, ScopeRegistryProvider, SearchInput, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, Separator, type ServerMessage, SignedIn, SignedOut, Skeleton, SkeletonAvatar, SkeletonCard, SkeletonList, SkeletonTable, SkeletonText, Switch, type SyncResult, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ToastProvider, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCanvasResult, type UseCronMonitorResult, type UseGameRoomResult, type UsePresenceRoomResult, type UseR2FilesReturn, type UseYjsFieldResult, type UseYjsRoomResult, type UseYjsTextResult, type User, type UserCredits, type UserInfo, type UserKarma, type UserProfile, type ViewportClient, applyDeepSpaceTheme, applyUIThemeTokens, authClient, badgeVariants, buttonVariants, clearAuthToken, clearDeepSpaceTheme, clientBuild, cn, createDecoder, createEncoder, decodeAiStreamChunk, detectEnvironment, dispatch, encode, encodeAwarenessMessage, encodeSyncStep1, encodeSyncStep2, encodeUpdate, formatFileSize, formatFullTimestamp, formatMessageTime, getApiUrl, getAuthToken, getAuthUrl, getConversationDisplayName, getConversationParticipantIds, getEnvironmentConfig, getMessageType, getPlatformWorkerUrl, getThreadCounts, getUserColor, groupReactionsForMessage, handleAwarenessMessage, handleSyncMessage, hasContent, integration, isDMConversation, isDarkColor, isImageFile, isLocalDev, isProduction, parseMessageMetadata, parseSseLine, readThemeFromDOM, readVarUint, readVarUint8Array, resetEnvironmentCache, serverBuild, shouldGroupMessages, signIn, signOut, toConnectionStatus, toUint8Array, useAuth, useAuthUser, useCanvas, useChannelMembers, useChannels, useCommunities, useConversation, useConversations, useCronMonitor, useDisplayName, useGameRoom, useInbox, useIsDarkTheme, useMessages, useMutations, usePlatform, usePlatformWS, usePosts, usePresence, usePresenceRoom, useQuery, useR2Files, useReactions, useReadReceipts, useRecordContext, useSession, useToast, useUser, useUserLookup, useUsers, useYjsField, useYjsRoom, useYjsText, writeVarUint, writeVarUint8Array };
|
package/dist/index.js
CHANGED
|
@@ -4703,6 +4703,73 @@ var integration = {
|
|
|
4703
4703
|
}
|
|
4704
4704
|
};
|
|
4705
4705
|
|
|
4706
|
+
// src/client/ai-stream.ts
|
|
4707
|
+
function parseSseLine(line) {
|
|
4708
|
+
if (!line) return null;
|
|
4709
|
+
if (line.startsWith(":")) return null;
|
|
4710
|
+
if (!line.startsWith("data:")) return null;
|
|
4711
|
+
const raw = line.slice(5).replace(/^ /, "").replace(/\r$/, "");
|
|
4712
|
+
if (raw === "[DONE]") return null;
|
|
4713
|
+
try {
|
|
4714
|
+
const parsed = JSON.parse(raw);
|
|
4715
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
4716
|
+
return parsed;
|
|
4717
|
+
} catch {
|
|
4718
|
+
return null;
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4721
|
+
function decodeAiStreamChunk(chunk) {
|
|
4722
|
+
if (typeof chunk.type !== "string") return null;
|
|
4723
|
+
switch (chunk.type) {
|
|
4724
|
+
case "text-delta": {
|
|
4725
|
+
const delta = typeof chunk.delta === "string" ? chunk.delta : "";
|
|
4726
|
+
if (!delta) return null;
|
|
4727
|
+
return { type: "append-text", delta };
|
|
4728
|
+
}
|
|
4729
|
+
case "tool-input-available": {
|
|
4730
|
+
if (typeof chunk.toolCallId !== "string" || typeof chunk.toolName !== "string") return null;
|
|
4731
|
+
return {
|
|
4732
|
+
type: "upsert-tool-call",
|
|
4733
|
+
toolCallId: chunk.toolCallId,
|
|
4734
|
+
toolName: chunk.toolName,
|
|
4735
|
+
input: chunk.input
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
case "tool-output-available": {
|
|
4739
|
+
if (typeof chunk.toolCallId !== "string") return null;
|
|
4740
|
+
const result = "output" in chunk ? chunk.output : null;
|
|
4741
|
+
return { type: "finalize-tool-call", toolCallId: chunk.toolCallId, result };
|
|
4742
|
+
}
|
|
4743
|
+
case "tool-input-error": {
|
|
4744
|
+
if (typeof chunk.toolCallId !== "string" || typeof chunk.toolName !== "string") return null;
|
|
4745
|
+
const errorText = typeof chunk.errorText === "string" ? chunk.errorText : "Tool input rejected";
|
|
4746
|
+
return {
|
|
4747
|
+
type: "fail-tool-input",
|
|
4748
|
+
toolCallId: chunk.toolCallId,
|
|
4749
|
+
toolName: chunk.toolName,
|
|
4750
|
+
input: chunk.input,
|
|
4751
|
+
errorText
|
|
4752
|
+
};
|
|
4753
|
+
}
|
|
4754
|
+
case "tool-output-error": {
|
|
4755
|
+
if (typeof chunk.toolCallId !== "string") return null;
|
|
4756
|
+
const errorText = typeof chunk.errorText === "string" ? chunk.errorText : "Tool execution failed";
|
|
4757
|
+
return { type: "fail-tool-output", toolCallId: chunk.toolCallId, errorText };
|
|
4758
|
+
}
|
|
4759
|
+
case "error": {
|
|
4760
|
+
const errorText = typeof chunk.errorText === "string" ? chunk.errorText : "Stream error";
|
|
4761
|
+
return { type: "stream-error", errorText };
|
|
4762
|
+
}
|
|
4763
|
+
case "abort":
|
|
4764
|
+
return { type: "abort" };
|
|
4765
|
+
// Forward-compat: silently ignore lifecycle markers (start/finish,
|
|
4766
|
+
// start-step/finish-step), text-start/-end, tool-input-start/-delta,
|
|
4767
|
+
// reasoning-*, source-*, message-metadata.
|
|
4768
|
+
default:
|
|
4769
|
+
return null;
|
|
4770
|
+
}
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4706
4773
|
// src/ui/utils.ts
|
|
4707
4774
|
import { clsx } from "clsx";
|
|
4708
4775
|
import { twMerge } from "tailwind-merge";
|
|
@@ -6302,6 +6369,7 @@ export {
|
|
|
6302
6369
|
cn,
|
|
6303
6370
|
createDecoder,
|
|
6304
6371
|
createEncoder,
|
|
6372
|
+
decodeAiStreamChunk,
|
|
6305
6373
|
detectEnvironment,
|
|
6306
6374
|
dispatch,
|
|
6307
6375
|
encode,
|
|
@@ -6333,6 +6401,7 @@ export {
|
|
|
6333
6401
|
isLocalDev,
|
|
6334
6402
|
isProduction,
|
|
6335
6403
|
parseMessageMetadata,
|
|
6404
|
+
parseSseLine,
|
|
6336
6405
|
readThemeFromDOM,
|
|
6337
6406
|
readVarUint,
|
|
6338
6407
|
readVarUint8Array,
|