@lovable.dev/sdk 0.1.8 → 0.1.10
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 +3 -131
- package/dist/index.d.ts +63 -651
- package/dist/index.js +55 -73
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ const project = await client.createProject(workspaces[0].id, {
|
|
|
31
31
|
// 2. Wait for the AI response and get the preview URL
|
|
32
32
|
const response = await client.waitForResponse(project.id);
|
|
33
33
|
console.log(response.content); // AI's response text
|
|
34
|
-
console.log(response.messageId); // AI message ID
|
|
34
|
+
console.log(response.messageId); // AI message ID
|
|
35
35
|
console.log(response.previewUrl); // Preview URL for the project
|
|
36
36
|
|
|
37
37
|
// 3. Send a follow-up chat message
|
|
@@ -89,66 +89,6 @@ The `continuation` option on `chat()` overrides prompt cache reuse behavior. API
|
|
|
89
89
|
| `"fresh_build"` | Force full prompt rebuild |
|
|
90
90
|
| `"allow_expired_cache"` | Skip expiry check only |
|
|
91
91
|
|
|
92
|
-
### Using a custom model
|
|
93
|
-
|
|
94
|
-
You can route the main agent to a custom OpenAI-compatible endpoint (for example your own inference base URL):
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
await client.chat(project.id, {
|
|
98
|
-
message: "Add a dark mode toggle",
|
|
99
|
-
customModel: {
|
|
100
|
-
endpoint: "https://my-vllm.example.com/v1",
|
|
101
|
-
apiKey: "sk-...",
|
|
102
|
-
modelName: "my-org/my-model-id",
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Optional `customModelDisableRace` on `chat()` (JSON field `custom_model_disable_race`) skips staggered inference racing when the server supports it for your endpoint. Requires API-key authentication, same as other custom-model fields.
|
|
108
|
-
|
|
109
|
-
### Fetching message traces (`_dev`)
|
|
110
|
-
|
|
111
|
-
Trace APIs are available under the `_dev` namespace. These are not part of the stable v1 surface and may change without notice.
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
const response = await client.waitForResponse(project.id);
|
|
115
|
-
|
|
116
|
-
// Fetch all traces for the message
|
|
117
|
-
const traces = await client._dev.getMessageTraces(project.id, response.messageId);
|
|
118
|
-
console.log(traces.spans);
|
|
119
|
-
|
|
120
|
-
// Filter by purpose (e.g. only the main agent span)
|
|
121
|
-
const agentTraces = await client._dev.getMessageTraces(project.id, response.messageId, {
|
|
122
|
-
purposes: ["main_agent"],
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// Batch fetch traces for multiple messages
|
|
126
|
-
const result = await client._dev.getMessageTracesBatch([
|
|
127
|
-
{ projectId: "proj-1", messageId: "msg-1" },
|
|
128
|
-
{ projectId: "proj-2", messageId: "msg-2" },
|
|
129
|
-
], { purposes: ["main_agent"], concurrency: 5 });
|
|
130
|
-
|
|
131
|
-
for (const [messageId, trace] of result.traces) {
|
|
132
|
-
console.log(messageId, trace.spans.length);
|
|
133
|
-
}
|
|
134
|
-
for (const [messageId, error] of result.errors) {
|
|
135
|
-
console.error(messageId, error.message);
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### Replaying reviewers (`_dev`)
|
|
140
|
-
|
|
141
|
-
Re-run quality reviewers (e.g. `project_success_v3`, `user_sentiment`) for past assistant messages. Requires an API key with project write access; not part of the stable v1 OpenAPI bundle (types live in this SDK).
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
const out = await client._dev.replayReviews(project.id, {
|
|
145
|
-
items: [{ response_message_id: "aimsg_..." }],
|
|
146
|
-
reviewer_types: ["project_success_v3", "user_sentiment"],
|
|
147
|
-
concurrency: 4,
|
|
148
|
-
});
|
|
149
|
-
console.log(out.results.items);
|
|
150
|
-
```
|
|
151
|
-
|
|
152
92
|
## API Reference
|
|
153
93
|
|
|
154
94
|
### `LovableClient`
|
|
@@ -203,9 +143,7 @@ Options:
|
|
|
203
143
|
- `message` (required): The message to send
|
|
204
144
|
- `files` (optional): Array of files to attach (browser `File` objects or `FileInput` objects)
|
|
205
145
|
- `chatOnly` (optional): If true, only chat without making code changes
|
|
206
|
-
- `
|
|
207
|
-
- `customModelDisableRace` (optional): Skip staggered inference racing for allowlisted custom model hosts (JSON `custom_model_disable_race`). API-key auth only; see [Using a custom model](#using-a-custom-model)
|
|
208
|
-
- `continuation` (optional): Override prompt cache continuation behavior (`"force"` | `"fresh_build"` | `"allow_expired_cache"`). API-key auth only. See [Controlling prompt cache continuation](#controlling-prompt-cache-continuation)
|
|
146
|
+
- `continuation` (optional): Override prompt cache continuation behavior (`"force"` | `"fresh_build"` | `"allow_expired_cache"`). API-key auth only. See [Continuation override](#continuation-override)
|
|
209
147
|
|
|
210
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.
|
|
211
149
|
|
|
@@ -218,7 +156,7 @@ Use this after `chat()` or after `createProject()` with `initialMessage`.
|
|
|
218
156
|
Returns:
|
|
219
157
|
|
|
220
158
|
- `content` (string): The AI's full response text
|
|
221
|
-
- `messageId` (string): The AI message ID
|
|
159
|
+
- `messageId` (string): The AI message ID
|
|
222
160
|
- `previewUrl` (string): The project's preview URL
|
|
223
161
|
|
|
224
162
|
Options:
|
|
@@ -308,48 +246,6 @@ Options:
|
|
|
308
246
|
|
|
309
247
|
Throws an error if the remix fails or timeout is reached.
|
|
310
248
|
|
|
311
|
-
#### `_dev` (developer/experimental APIs)
|
|
312
|
-
|
|
313
|
-
These methods are not part of the stable v1 surface and may change without notice.
|
|
314
|
-
|
|
315
|
-
##### `_dev.getMessageTraces(projectId: string, messageId: string, options?): Promise<MessageTracesResponse>`
|
|
316
|
-
|
|
317
|
-
Fetch Braintrust trace spans for a specific chat message. The `messageId` is available from the `ChatResponse` returned by `waitForResponse()`.
|
|
318
|
-
|
|
319
|
-
When a purpose has multiple spans (e.g. `main_agent` across turns), only the last span is returned — it contains the full accumulated context.
|
|
320
|
-
|
|
321
|
-
Options:
|
|
322
|
-
|
|
323
|
-
- `purposes` (optional): Filter spans by purpose (e.g. `["main_agent", "knowledge_rag"]`)
|
|
324
|
-
|
|
325
|
-
Returns:
|
|
326
|
-
|
|
327
|
-
- `message_id` (string): The message ID
|
|
328
|
-
- `braintrust_span_id` (string): The Braintrust span ID
|
|
329
|
-
- `root_span_id` (string): The root span ID
|
|
330
|
-
- `spans` (TraceSpan[]): The filtered trace spans
|
|
331
|
-
|
|
332
|
-
##### `_dev.getMessageTracesBatch(queries, options?): Promise<BatchTracesResult>`
|
|
333
|
-
|
|
334
|
-
Fetch traces for multiple messages across projects in parallel.
|
|
335
|
-
|
|
336
|
-
- `queries`: Array of `{ projectId, messageId }` to fetch
|
|
337
|
-
- `options.purposes` (optional): Filter spans by purpose (applied to all queries)
|
|
338
|
-
- `options.concurrency` (optional): Max parallel requests (default: 5)
|
|
339
|
-
|
|
340
|
-
Returns:
|
|
341
|
-
|
|
342
|
-
- `traces`: Map of messageId → `MessageTracesResponse`
|
|
343
|
-
- `errors`: Map of messageId → `Error` (for failed requests)
|
|
344
|
-
|
|
345
|
-
##### `_dev.replayReviews(projectId: string, body): Promise<ReplayReviewsResponse>`
|
|
346
|
-
|
|
347
|
-
Re-run reviewers for one or more assistant (`response`) messages. Requires an API key with project write access.
|
|
348
|
-
|
|
349
|
-
- `body.items`: Each entry must include `response_message_id` (assistant message id). Optional per-item `reviewer_types`.
|
|
350
|
-
- `body.reviewer_types` (optional): Global default when an item omits `reviewer_types`.
|
|
351
|
-
- `body.concurrency` (optional): Parallel items (default 4, max 16).
|
|
352
|
-
|
|
353
249
|
##### `inviteCollaborator(workspaceId: string, options): Promise<WorkspaceMembershipResponse>`
|
|
354
250
|
|
|
355
251
|
Invite a user to a workspace.
|
|
@@ -382,12 +278,8 @@ import type {
|
|
|
382
278
|
CreateProjectOptions,
|
|
383
279
|
ChatResponse,
|
|
384
280
|
ContinuationOverride,
|
|
385
|
-
CustomModelConfig,
|
|
386
281
|
FileInput,
|
|
387
282
|
RemixProjectOptions,
|
|
388
|
-
TracePurpose,
|
|
389
|
-
TraceSpan,
|
|
390
|
-
MessageTracesResponse,
|
|
391
283
|
// ... etc
|
|
392
284
|
} from "@lovable.dev/sdk";
|
|
393
285
|
```
|
|
@@ -404,18 +296,6 @@ interface FileInput {
|
|
|
404
296
|
}
|
|
405
297
|
```
|
|
406
298
|
|
|
407
|
-
### `CustomModelConfig`
|
|
408
|
-
|
|
409
|
-
Configuration for routing the main agent to a custom OpenAI-compatible endpoint:
|
|
410
|
-
|
|
411
|
-
```typescript
|
|
412
|
-
interface CustomModelConfig {
|
|
413
|
-
endpoint: string; // Base URL (e.g., "https://my-vllm.example.com/v1")
|
|
414
|
-
apiKey: string; // API key for the endpoint
|
|
415
|
-
modelName: string; // Model identifier (e.g., "my-org/my-model-id")
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
299
|
### `ContinuationOverride`
|
|
420
300
|
|
|
421
301
|
Controls prompt cache continuation behavior for a message:
|
|
@@ -427,11 +307,3 @@ type ContinuationOverride = "force" | "fresh_build" | "allow_expired_cache";
|
|
|
427
307
|
- `"force"` — skip all continuation checks (force continuation)
|
|
428
308
|
- `"fresh_build"` — force a full prompt rebuild from scratch
|
|
429
309
|
- `"allow_expired_cache"` — skip cache expiry check but respect other continuation checks
|
|
430
|
-
|
|
431
|
-
### `TracePurpose`
|
|
432
|
-
|
|
433
|
-
Available trace span purposes:
|
|
434
|
-
|
|
435
|
-
```typescript
|
|
436
|
-
type TracePurpose = "main_agent" | "codebase_rag" | "knowledge_rag" | "review";
|
|
437
|
-
```
|