@lovable.dev/sdk 0.1.9 → 1.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  TypeScript SDK for the Lovable API.
4
4
 
5
- Currently in preview.
5
+ Stable for the public API v1 surface and versioned with semver.
6
6
 
7
7
  ## Installation
8
8
 
@@ -28,11 +28,11 @@ const project = await client.createProject(workspaces[0].id, {
28
28
  initialMessage: "Create a todo app with authentication"
29
29
  });
30
30
 
31
- // 2. Wait for the AI response and get the preview URL
32
- const response = await client.waitForResponse(project.id);
33
- console.log(response.content); // AI's response text
34
- console.log(response.messageId); // AI message ID (for traces)
35
- console.log(response.previewUrl); // Preview URL for the project
31
+ // 2. Wait for the AI response, then get the preview URL
32
+ const response = await client.waitForMessageCompletion(project.id, project.message_id);
33
+ console.log(response.content); // AI's response text
34
+ console.log(response.message_id); // AI message ID
35
+ console.log(client.getPreviewUrl(project.id)); // Preview URL for the project
36
36
 
37
37
  // 3. Send a follow-up chat message
38
38
  await client.chat(project.id, {
@@ -75,8 +75,10 @@ const { projectId } = await client.waitForRemix("source-project-id", jobId, {
75
75
  console.log(`Remixed project: ${projectId}`);
76
76
 
77
77
  // Send a follow-up message to the remixed project
78
- await client.chat(projectId, { message: "Add dark mode" });
79
- const response = await client.waitForResponse(projectId);
78
+ const followUp = await client.chat(projectId, { message: "Add dark mode" });
79
+ const response = await client.waitForMessageCompletion(projectId, followUp.message_id, {
80
+ threadId: followUp.thread_id,
81
+ });
80
82
  ```
81
83
 
82
84
  ### Continuation override
@@ -91,6 +93,8 @@ The `continuation` option on `chat()` overrides prompt cache reuse behavior. API
91
93
 
92
94
  ## API Reference
93
95
 
96
+ HTTPie examples live in [examples/httpie.md](examples/httpie.md).
97
+
94
98
  ### `LovableClient`
95
99
 
96
100
  #### Constructor
@@ -134,36 +138,84 @@ Options:
134
138
  - `initialMessage` (optional): Initial chat message to send to the AI agent
135
139
  - `files` (optional): Array of files to attach (browser `File` objects or `FileInput` objects)
136
140
 
137
- ##### `chat(projectId: string, options): Promise<void>`
141
+ ##### `getProject(projectId: string): Promise<ProjectResponse>`
142
+
143
+ Get a project by ID.
144
+
145
+ ##### `updateProject(projectId: string, options): Promise<ProjectResponse>`
146
+
147
+ Update supported project fields through `PATCH /v1/projects/{project_id}`.
148
+
149
+ Options:
150
+
151
+ - `display_name` (optional): Project display name
152
+ - `visibility` (optional): Project visibility (`"draft"` | `"private"` | `"public"` | `"workspace_view"`)
153
+
154
+ ##### `deleteProject(projectId: string): Promise<void>`
155
+
156
+ Soft-delete a project through `DELETE /v1/projects/{project_id}`.
157
+
158
+ ##### `chat(projectId: string, options): Promise<SendMessageResponse>`
138
159
 
139
160
  Send a chat message to a project's AI agent.
140
161
 
141
162
  Options:
142
163
 
143
164
  - `message` (required): The message to send
165
+ - `variantId` (optional): Variant ID from `createVariant()`. Omit to send the message to the project's main agent
144
166
  - `files` (optional): Array of files to attach (browser `File` objects or `FileInput` objects)
145
- - `chatOnly` (optional): If true, only chat without making code changes
146
167
  - `continuation` (optional): Override prompt cache continuation behavior (`"force"` | `"fresh_build"` | `"allow_expired_cache"`). API-key auth only. See [Continuation override](#continuation-override)
147
168
 
148
- Note: This is an asynchronous operation. The API accepts the message and processes it in the background. Use `waitForResponse()` to wait for the AI's reply.
169
+ The response includes the created `message_id` and its trajectory `thread_id`. Pass both to `waitForMessageCompletion()` to wait for the matching AI reply.
149
170
 
150
- ##### `waitForResponse(projectId: string, options?): Promise<ChatResponse>`
171
+ ##### `listMessages(projectId: string, options?): Promise<ListMessagesResponse>`
172
+
173
+ List recent project messages through `GET /v1/messages`.
174
+
175
+ ##### `getMessage(projectId: string, messageId: string, options?): Promise<GetMessageResponse>`
176
+
177
+ Get a message through `GET /v1/messages/{message_id}`. Pass `waitSeconds` for server-side long polling.
151
178
 
152
- Wait for the AI's response to a chat message. Connects to the project's message stream (SSE) and returns the full response once complete.
179
+ ##### `createVariant(projectId: string, options?): Promise<CreateVariantResponse>`
153
180
 
154
- Use this after `chat()` or after `createProject()` with `initialMessage`.
181
+ Create an independent variant from the project's current main branch, or from a specific full 40-character commit SHA.
182
+
183
+ Options:
184
+
185
+ - `label` (optional): Display name. Defaults to the next Draft number
186
+ - `baseSha` (optional): Full 40-character commit SHA to base the variant branch on
155
187
 
156
188
  Returns:
157
189
 
190
+ - `variant_id` (string): The variant ID to pass to `chat()`
191
+ - `label` (string): The variant's display name
192
+ - `branch` (string): The git branch attached to the variant
193
+ - `thread_id` (string): The trajectory thread driving the variant
194
+
195
+ The API returns `403 variants_not_enabled` when variants are unavailable for the authenticated user and project workspace.
196
+
197
+ ##### `waitForMessageCompletion(projectId: string, messageId: string, options?): Promise<MessageCompletionResult>`
198
+
199
+ Wait for a specific message's AI response to finish. Pass the `message_id` from `chat()` or from `createProject()` with `initialMessage` (and the `thread_id` via `options.threadId` for non-main threads).
200
+
201
+ Use `getPreviewUrl(projectId)` to construct the preview URL.
202
+
203
+ Returns:
204
+
205
+ - `status` (`"completed" | "awaiting_input" | "stopped" | "timeout" | "error"`): Terminal state
158
206
  - `content` (string): The AI's full response text
159
- - `messageId` (string): The AI message ID
160
- - `previewUrl` (string): The project's preview URL
207
+ - `message_id` (string): The AI message ID
208
+ - `awaiting_input` (optional): Present when `status` is `"awaiting_input"` — a non-headless turn paused by a human-in-the-loop tool. Carries the resumable `event_id`, `prev_session_id`, and optional `input_schema`
209
+ - `edit_id` / `commit_sha` / `summary` / `cost_credits` (optional): Result metadata
161
210
 
162
211
  Options:
163
212
 
164
- - `timeout` (optional): Maximum time to wait in ms (default: 300000 = 5 minutes)
213
+ - `threadId` (optional): Trajectory thread returned by `chat()`
214
+ - `timeout` (optional): Maximum total time to wait in ms (default: 600000 = 10 minutes)
215
+
216
+ ##### `waitForResponse(projectId: string, options?): Promise<ChatResponse>`
165
217
 
166
- Throws an error if the stream fails or timeout is reached.
218
+ Deprecated compatibility helper. Prefer `waitForMessageCompletion(projectId, messageId)`.
167
219
 
168
220
  ##### `getPreviewUrl(projectId: string): string`
169
221
 
@@ -246,27 +298,6 @@ Options:
246
298
 
247
299
  Throws an error if the remix fails or timeout is reached.
248
300
 
249
- ##### `inviteCollaborator(workspaceId: string, options): Promise<WorkspaceMembershipResponse>`
250
-
251
- Invite a user to a workspace.
252
-
253
- Options:
254
-
255
- - `email` (required): Email address of the user to invite
256
- - `role` (optional): Role to assign (`"admin"` | `"collaborator"` | `"member"` | `"viewer"`)
257
-
258
- ##### `listWorkspaceMembers(workspaceId: string): Promise<WorkspaceMembershipResponse[]>`
259
-
260
- List all members of a workspace.
261
-
262
- ##### `removeWorkspaceMember(workspaceId: string, userId: string): Promise<void>`
263
-
264
- Remove a member from a workspace.
265
-
266
- ##### `getProject(projectId: string): Promise<ProjectResponse>`
267
-
268
- Get project details by ID.
269
-
270
301
  ## Types
271
302
 
272
303
  The SDK exports TypeScript types for all API responses. See `src/types.ts` for the full list.
@@ -276,7 +307,7 @@ import type {
276
307
  WorkspaceWithMembership,
277
308
  ProjectResponse,
278
309
  CreateProjectOptions,
279
- ChatResponse,
310
+ MessageCompletionResult,
280
311
  ContinuationOverride,
281
312
  FileInput,
282
313
  RemixProjectOptions,