@@ -3,41 +3,36 @@ import type {
33 ProjectType as PlatformProjectType ,
44 PlatformCodeGenArgs ,
55 WebSocketMessage ,
6+ ImageAttachment as PlatformImageAttachment ,
7+ AgentState as PlatformAgentState ,
68} from './protocol' ;
79import type { RetryConfig } from './retry' ;
810export type { RetryConfig } from './retry' ;
911
1012export type BehaviorType = PlatformBehaviorType ;
1113export type ProjectType = PlatformProjectType ;
14+ export type ImageAttachment = PlatformImageAttachment ;
15+ export type AgentState = PlatformAgentState ;
1216
13- // Ephemeral, optional credentials (not persisted by SDK).
1417export type Credentials = NonNullable < PlatformCodeGenArgs [ 'credentials' ] > ;
15-
1618export type CodeGenArgs = PlatformCodeGenArgs ;
1719
1820export type BuildOptions = Omit < CodeGenArgs , 'query' > & {
19- /**
20- * If true (default), connect to the agent websocket immediately.
21- */
2221 autoConnect ?: boolean ;
23- /**
24- * If true (default), send `{ type: 'generate_all' }` after websocket connection.
25- */
2622 autoGenerate ?: boolean ;
27- /**
28- * Called for each blueprint chunk emitted by the create-agent stream.
29- */
3023 onBlueprintChunk ?: ( chunk : string ) => void ;
3124} ;
3225
26+ export type TemplateFiles = Record < string , string > ;
27+
3328export type BuildStartEvent = {
3429 message ?: string ;
3530 agentId : string ;
3631 websocketUrl : string ;
3732 httpStatusUrl ?: string ;
3833 behaviorType ?: BehaviorType ;
3934 projectType ?: string ;
40- template ?: { name : string ; files ?: unknown } ;
35+ template ?: { name : string ; files ?: TemplateFiles } ;
4136} ;
4237
4338export type ApiResponse < T > =
@@ -65,10 +60,44 @@ export type AppListItem = {
6560 previewUrl ?: string ;
6661} ;
6762
68- export type AppDetails = Record < string , unknown > & {
63+ export type AppDetails = {
6964 id : string ;
7065 previewUrl ?: string ;
7166 cloudflareUrl ?: string ;
67+ title ?: string ;
68+ description ?: string | null ;
69+ framework ?: string | null ;
70+ visibility ?: 'public' | 'private' ;
71+ createdAt ?: string | null ;
72+ updatedAt ?: string | null ;
73+ [ key : string ] : string | null | undefined ;
74+ } ;
75+
76+ export type AppVisibility = 'public' | 'private' ;
77+
78+ export type AppWithFavoriteStatus = AppListItem & {
79+ isFavorite : boolean ;
80+ updatedAtFormatted ?: string ;
81+ } ;
82+
83+ export type VisibilityUpdateResult = {
84+ app : {
85+ id : string ;
86+ title : string ;
87+ visibility : AppVisibility ;
88+ updatedAt : string | null ;
89+ } ;
90+ message : string ;
91+ } ;
92+
93+ export type ToggleResult = {
94+ isFavorite ?: boolean ;
95+ isStarred ?: boolean ;
96+ } ;
97+
98+ export type DeleteResult = {
99+ success : boolean ;
100+ message : string ;
72101} ;
73102
74103export type AgentWsServerMessage = WebSocketMessage ;
@@ -82,7 +111,7 @@ export type AgentWsClientMessage =
82111 | { type : 'deploy' }
83112 | { type : 'get_conversation_state' }
84113 | { type : 'clear_conversation' }
85- | { type : 'user_suggestion' ; message : string ; images ?: unknown [ ] } ;
114+ | { type : 'user_suggestion' ; message : string ; images ?: ImageAttachment [ ] } ;
86115
87116export type AgentWebSocketMessage = AgentWsServerMessage | AgentWsClientMessage ;
88117
@@ -94,11 +123,9 @@ export type WsMessageOf<TType extends AgentWsServerMessage['type']> = Extract<
94123export type AgentEventMap = {
95124 'ws:open' : undefined ;
96125 'ws:close' : { code : number ; reason : string } ;
97- 'ws:error' : { error : unknown } ;
126+ 'ws:error' : { error : Error | string } ;
98127 'ws:reconnecting' : { attempt : number ; delayMs : number ; reason : 'close' | 'error' } ;
99- /** Server payload that isn't a well-formed typed message. */
100- 'ws:raw' : { raw : unknown } ;
101- /** Raw server->client message (typed) */
128+ 'ws:raw' : { raw : Record < string , unknown > } ;
102129 'ws:message' : AgentWsServerMessage ;
103130
104131 // High-level sugar events (typed)
@@ -130,14 +157,26 @@ export type AgentEventMap = {
130157 error : { error : string } ;
131158} ;
132159
160+ export type WsOpenEvent = Event ;
161+ export type WsCloseEvent = CloseEvent | { code ?: number ; reason ?: string } ;
162+ export type WsErrorEvent = Event | Error ;
163+ export type WsMessageEvent = MessageEvent | { data : string } ;
164+
165+ export type WebSocketEventMap = {
166+ open : WsOpenEvent ;
167+ close : WsCloseEvent ;
168+ error : WsErrorEvent ;
169+ message : WsMessageEvent ;
170+ } ;
171+
172+ export type WebSocketEventType = keyof WebSocketEventMap ;
173+ export type WebSocketEventListener < K extends WebSocketEventType > = ( event : WebSocketEventMap [ K ] ) => void ;
174+
133175export type WebSocketLike = {
134176 send : ( data : string ) => void ;
135177 close : ( ) => void ;
136- addEventListener ?: (
137- type : 'open' | 'close' | 'error' | 'message' ,
138- listener : ( event : unknown ) => void
139- ) => void ;
140- on ?: ( type : string , listener : ( ...args : unknown [ ] ) => void ) => void ;
178+ addEventListener ?< K extends WebSocketEventType > ( type : K , listener : WebSocketEventListener < K > ) : void ;
179+ on ?< K extends WebSocketEventType > ( type : K , listener : WebSocketEventListener < K > ) : void ;
141180} ;
142181
143182export type AgentConnectionOptions = {
@@ -208,18 +247,16 @@ export type SessionDeployable = {
208247
209248export type VibeClientOptions = {
210249 baseUrl : string ;
211- /**
212- * Current platform requirement: JWT access token. In future this will be minted from `apiKey`.
213- */
250+ /** JWT access token (or will be minted from apiKey). */
214251 token ?: string ;
215- /** Future: VibeSDK API key. */
252+ /** VibeSDK API key. */
216253 apiKey ?: string ;
217254 defaultHeaders ?: Record < string , string > ;
218- /** Used as Origin header for WS (optional but often required) . */
255+ /** Origin header for WebSocket connections . */
219256 websocketOrigin ?: string ;
220- /** Optional WebSocket factory for Node/Bun runtimes . */
257+ /** WebSocket factory - use runtime-specific factories from /browser, /worker, or /node . */
221258 webSocketFactory ?: AgentConnectionOptions [ 'webSocketFactory' ] ;
222259 fetchFn ?: typeof fetch ;
223- /** HTTP retry configuration for transient failures (5xx, network errors) . */
260+ /** HTTP retry config for transient failures. */
224261 retry ?: RetryConfig ;
225262} ;
0 commit comments