@base44-preview/platform 0.1.0-pr.319.cf89f7f → 0.1.0-pr.332.00d7174
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 +71 -124
- package/dist/client/client.d.ts +30 -9
- package/dist/client/client.js +30 -7
- package/dist/client/client.types.d.ts +9 -11
- package/dist/client/errors.d.ts +41 -4
- package/dist/client/errors.js +39 -2
- package/dist/client/errors.types.d.ts +98 -2
- package/dist/client/index.d.ts +6 -5
- package/dist/client/index.js +1 -1
- package/dist/client/modules/builder-protocol.d.ts +16 -5
- package/dist/client/modules/builder-protocol.js +30 -8
- package/dist/client/modules/builder-socket.d.ts +10 -5
- package/dist/client/modules/builder-socket.js +114 -87
- package/dist/client/modules/builder-subscription.d.ts +2 -2
- package/dist/client/modules/builder.d.ts +1 -2
- package/dist/client/modules/builder.events.generated.d.ts +2194 -0
- package/dist/client/modules/builder.events.generated.js +3 -0
- package/dist/client/modules/builder.events.types.d.ts +70 -361
- package/dist/client/modules/builder.js +2 -2
- package/dist/client/modules/builder.types.d.ts +169 -23
- package/dist/server/index.d.ts +2 -5
- package/dist/server/index.js +1 -2
- package/dist/server/server-url.d.ts +2 -0
- package/dist/{shared → server}/server-url.js +1 -1
- package/dist/server/server.d.ts +2 -2
- package/dist/server/server.js +3 -6
- package/dist/server/server.types.d.ts +2 -7
- package/package.json +17 -13
- package/dist/server/errors.d.ts +0 -15
- package/dist/server/errors.js +0 -18
- package/dist/server/errors.types.d.ts +0 -4
- package/dist/server/errors.types.js +0 -1
- package/dist/server/modules/webhooks-signature.d.ts +0 -11
- package/dist/server/modules/webhooks-signature.js +0 -65
- package/dist/server/modules/webhooks.d.ts +0 -3
- package/dist/server/modules/webhooks.events.generated.d.ts +0 -174
- package/dist/server/modules/webhooks.events.generated.js +0 -3
- package/dist/server/modules/webhooks.js +0 -77
- package/dist/server/modules/webhooks.types.d.ts +0 -102
- package/dist/server/modules/webhooks.types.js +0 -1
- package/dist/shared/server-url.d.ts +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated from asyncapi.json by scripts/gen-events.mjs. Do not edit; run `npm run gen:events`.
|
|
2
|
+
/** @internal */
|
|
3
|
+
export const serverEventNames = ["message.updated", "message.removed", "app.status_changed", "preview.reload_requested", "preview.navigation_requested", "queue.updated", "task.progressed", "image.resolved", "conversation.changed", "files.changed", "branch.deleted", "repository.changed", "pull_request.changed", "session.ended", "room.access_denied", "room.access_revoked", "room.snapshot_unavailable", "app.snapshot"];
|
|
@@ -1,368 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export interface ToolQuestionArguments {
|
|
38
|
-
/** Questions presented to the user. */
|
|
39
|
-
questions?: ToolQuestion[];
|
|
40
|
-
}
|
|
41
|
-
/** A requested secret field. The secret value is never sent over the socket. */
|
|
42
|
-
export interface ToolSecretField {
|
|
43
|
-
/** Requested secret name. */
|
|
44
|
-
secretName?: string;
|
|
45
|
-
/** Optional explanation of where to obtain it. */
|
|
46
|
-
description?: string;
|
|
47
|
-
}
|
|
48
|
-
/** `set_secrets` arguments. */
|
|
49
|
-
export interface ToolSecretArguments {
|
|
50
|
-
/** Requested secret fields. */
|
|
51
|
-
secrets_schema?: ToolSecretField[];
|
|
52
|
-
}
|
|
53
|
-
/** A package operation. Versions and package-manager output are excluded. */
|
|
54
|
-
export interface ToolPackageOperation {
|
|
55
|
-
/** Package name. */
|
|
56
|
-
name?: string;
|
|
57
|
-
/** Requested package operation. */
|
|
58
|
-
action?: string;
|
|
59
|
-
}
|
|
60
|
-
/** `install_npm_package` arguments. */
|
|
61
|
-
export interface ToolPackageArguments {
|
|
62
|
-
/** Requested package operations. */
|
|
63
|
-
packages?: ToolPackageOperation[];
|
|
64
|
-
}
|
|
65
|
-
/** An add-only builder plan update. */
|
|
66
|
-
export interface ToolPlanUpdate {
|
|
67
|
-
/** Update action. */
|
|
68
|
-
action?: string;
|
|
69
|
-
/** Plan section key. */
|
|
70
|
-
section?: string;
|
|
71
|
-
/** Optional user-facing section label. */
|
|
72
|
-
section_label?: string;
|
|
73
|
-
/** Plan point. */
|
|
74
|
-
text?: string;
|
|
75
|
-
}
|
|
76
|
-
/** `update_plan` arguments. */
|
|
77
|
-
export interface ToolPlanArguments {
|
|
78
|
-
/** Plan updates in their emitted order. */
|
|
79
|
-
updates?: ToolPlanUpdate[];
|
|
80
|
-
/** Base plan sections the builder considers sufficiently specified. */
|
|
81
|
-
sections_with_enough?: string[];
|
|
82
|
-
}
|
|
83
|
-
/** `generate_prd` arguments: the user's own plan. In plan mode the message `content` beside it can be empty. */
|
|
84
|
-
export interface ToolPrdArguments {
|
|
85
|
-
/** App or feature name. */
|
|
86
|
-
app_name?: string;
|
|
87
|
-
/** What is being built and why. */
|
|
88
|
-
intent_and_goal?: string;
|
|
89
|
-
/** Who uses it and their roles. */
|
|
90
|
-
audience_and_roles?: string;
|
|
91
|
-
/** End-to-end user flows. */
|
|
92
|
-
core_flows?: string[];
|
|
93
|
-
/** Specific technical requirements. */
|
|
94
|
-
technical_requirements?: string;
|
|
95
|
-
/** Design preferences. */
|
|
96
|
-
design_preferences?: string;
|
|
97
|
-
/** Build or plan declaration, when the builder asks for one. */
|
|
98
|
-
prd_type?: string;
|
|
99
|
-
/** Store platform settled in planning, for e-commerce plans. */
|
|
100
|
-
store_platform?: string;
|
|
101
|
-
/** Engine settled in planning, for game plans. */
|
|
102
|
-
game_engine?: string;
|
|
103
|
-
}
|
|
104
|
-
/** Image, game-image and video generation arguments. */
|
|
105
|
-
export interface ToolMediaArguments {
|
|
106
|
-
/** Visible media label. */
|
|
107
|
-
label?: string;
|
|
108
|
-
/** Requested image or video aspect ratio. */
|
|
109
|
-
aspect_ratio?: string;
|
|
110
|
-
}
|
|
111
|
-
/** `update_entities` and `delete_entities` arguments; the entity is in `display.entity_name`. */
|
|
112
|
-
export interface ToolEntityMutationArguments {
|
|
113
|
-
/** The agent's summary of the change. Queries and record values are never included. */
|
|
114
|
-
summary?: string;
|
|
115
|
-
}
|
|
116
|
-
/** The public arguments of a tool that declares them; narrow by the tool call's `name`. */
|
|
117
|
-
export type ToolArguments = ToolQuestionArguments | ToolSecretArguments | ToolPackageArguments | ToolPlanArguments | ToolPrdArguments | ToolMediaArguments | ToolEntityMutationArguments;
|
|
118
|
-
/** Generated-media state. Raw generation prompts and IDs are never included. */
|
|
119
|
-
export interface ToolMediaResult {
|
|
120
|
-
/** Placeholder URL, used to associate an `image.resolved` event with this tool. */
|
|
121
|
-
placeholder_url?: string;
|
|
122
|
-
/** Current media-generation status. */
|
|
123
|
-
status?: "pending" | "completed" | "failed";
|
|
124
|
-
/** Generated asset URL, once available. */
|
|
125
|
-
image_url?: string | null;
|
|
126
|
-
}
|
|
127
|
-
/** An answer to a clarifying question. Secret-form input is never included. */
|
|
128
|
-
export interface ToolQuestionAnswer {
|
|
129
|
-
/** Zero-based question index. */
|
|
130
|
-
question_index?: number;
|
|
131
|
-
/** Label selected for a single-select question. */
|
|
132
|
-
selected_label?: string;
|
|
133
|
-
/** Labels selected for a multi-select question. */
|
|
134
|
-
selected_labels?: string[];
|
|
135
|
-
/** User-provided free-text answer. Structural filtering does not redact prose. */
|
|
136
|
-
custom_text?: string;
|
|
137
|
-
}
|
|
138
|
-
/** Clarifying-question answers. */
|
|
139
|
-
export interface ToolQuestionInput {
|
|
140
|
-
/** Answers supplied to the question card. */
|
|
141
|
-
answers?: ToolQuestionAnswer[];
|
|
142
|
-
}
|
|
143
|
-
/** Why a safety guard parked a call for approval. Only present while the call waits. */
|
|
144
|
-
export interface ToolGuardApproval {
|
|
145
|
-
/** Guard identifier, e.g. `exec_tool_send_email` or `bash_approval`. */
|
|
146
|
-
guard: string;
|
|
147
|
-
/** Human-readable reason, for guards whose reason never quotes input (not shell commands). */
|
|
148
|
-
reason?: string;
|
|
149
|
-
/** The details the guard declares public; commands and record data are never included. */
|
|
150
|
-
details?: {
|
|
151
|
-
/** Entity method the code calls, e.g. `delete`. */
|
|
152
|
-
method?: string;
|
|
153
|
-
/** The agent's summary of what the code does. */
|
|
154
|
-
summary?: string;
|
|
155
|
-
/** Entity whose access rules change. */
|
|
156
|
-
entity_name?: string;
|
|
157
|
-
/** How the access rules change. */
|
|
158
|
-
change_type?: string;
|
|
159
|
-
/** Access operations whose rules change. */
|
|
160
|
-
changed_ops?: string[];
|
|
161
|
-
/** Backend function under test. */
|
|
162
|
-
function_name?: string;
|
|
163
|
-
/** The guard could not verify the function's source. */
|
|
164
|
-
inspection_failed?: boolean;
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
/** Public progress of a builder tool call. Only what the tool and its guard declare public is present. */
|
|
168
|
-
export interface ToolCall {
|
|
169
|
-
/** Stable tool call identifier. */
|
|
170
|
-
id?: string;
|
|
171
|
-
/** Tool name. */
|
|
172
|
-
name?: string;
|
|
173
|
-
/** Current execution state. */
|
|
174
|
-
status?: "running" | "success" | "error" | "stopped" | "waiting_for_user_input";
|
|
175
|
-
/** Whether the tool needs a user response through the partner backend. */
|
|
176
|
-
requires_user_input?: boolean;
|
|
177
|
-
/** Whether the builder auto-approved the operation. */
|
|
178
|
-
auto_approved?: boolean;
|
|
179
|
-
/** Whether the mutation was applied. */
|
|
180
|
-
mutation_applied?: boolean | null;
|
|
181
|
-
/** Kind of response a parked call waits for. */
|
|
182
|
-
waiting_on?: {
|
|
183
|
-
/** Kind of response expected. */
|
|
184
|
-
kind?: "approval" | "choice" | "input";
|
|
185
|
-
};
|
|
186
|
-
/** The tool's public arguments; absent for tools that declare none and for partial streaming arguments. */
|
|
187
|
-
arguments?: ToolArguments;
|
|
188
|
-
/** What a file, execution or entity tool touched. */
|
|
189
|
-
display?: ToolDisplay;
|
|
190
|
-
/** Clarifying-question answers. */
|
|
191
|
-
user_input?: ToolQuestionInput;
|
|
192
|
-
/** Generated media, once the call is not waiting on a guard: the image tool's state, or a URL alone
|
|
193
|
-
* (a game asset's placeholder, which `image.resolved` replaces, or a finished video). */
|
|
194
|
-
results?: ToolMediaResult | string;
|
|
195
|
-
/** A parked call's guard, and its reason and details where the guard declares them. */
|
|
196
|
-
approval?: ToolGuardApproval;
|
|
197
|
-
}
|
|
198
|
-
/** Scalar parameters a chat UI needs while a turn runs. */
|
|
199
|
-
export interface MessageParams {
|
|
200
|
-
/** Identifier the sending client attached, to match its optimistic message. */
|
|
201
|
-
client_creation_id?: string;
|
|
202
|
-
/** The message was sent in plan mode. */
|
|
203
|
-
plan_mode?: boolean;
|
|
204
|
-
/** The message approves a plan. */
|
|
205
|
-
plan_approved?: boolean;
|
|
206
|
-
/** The message expects no AI reply. */
|
|
207
|
-
skip_ai_response?: boolean;
|
|
208
|
-
/** System message category. */
|
|
209
|
-
system_message_type?: string;
|
|
210
|
-
}
|
|
211
|
-
/** A public chat message. Replace the message with the same `id` as a whole. */
|
|
212
|
-
export interface ChatMessage {
|
|
213
|
-
/** Message identifier. */
|
|
214
|
-
id?: string;
|
|
215
|
-
/** Author category. System and hidden messages are never delivered. */
|
|
216
|
-
role?: "user" | "assistant";
|
|
217
|
-
/** Message text; structured content is withheld. Structural filtering is not prose redaction. */
|
|
218
|
-
content?: string | null;
|
|
219
|
-
/** Public tool progress. */
|
|
220
|
-
tool_calls?: ToolCall[] | null;
|
|
221
|
-
/** Message timestamp, without author identity. */
|
|
222
|
-
metadata?: {
|
|
223
|
-
/** ISO timestamp string. */
|
|
224
|
-
created_date?: string;
|
|
225
|
-
};
|
|
226
|
-
/** Checkpoint reference; mutations remain on the partner backend. */
|
|
227
|
-
checkpoint_id?: string | null;
|
|
228
|
-
/** Scalar message parameters. */
|
|
229
|
-
additional_message_params?: MessageParams;
|
|
230
|
-
}
|
|
231
|
-
/** Public builder state, without error diagnostics or billing context. */
|
|
232
|
-
export interface AppStatus {
|
|
233
|
-
/** Current builder state. */
|
|
234
|
-
state?: "ready" | "processing" | "error";
|
|
235
|
-
/** State timestamp. */
|
|
236
|
-
last_updated_date?: string | null;
|
|
237
|
-
/** The user message that started the turn, when a turn set this state. Quote it to Base44 support. */
|
|
238
|
-
turn_id?: string | null;
|
|
239
|
-
}
|
|
240
|
-
/** Branch scope carried by app events. Null or absent is the main branch. */
|
|
241
|
-
export interface BranchScoped {
|
|
242
|
-
/** Branch the change belongs to; null is main. */
|
|
243
|
-
branch_id?: string | null;
|
|
244
|
-
}
|
|
245
|
-
/** `message.updated`: a chat message was added or replaced. */
|
|
246
|
-
export interface MessageUpdated extends BranchScoped {
|
|
247
|
-
/** The whole message; replace the one with the same `id`. */
|
|
248
|
-
message: ChatMessage;
|
|
249
|
-
/** Conversation containing the message. */
|
|
250
|
-
conversation_id?: string | null;
|
|
251
|
-
}
|
|
252
|
-
/** `message.removed`: a message was removed or hidden. An `id` the viewer never saw is a no-op. */
|
|
253
|
-
export interface MessageRemoved extends BranchScoped {
|
|
254
|
-
/** Identifier of the message to remove. */
|
|
255
|
-
message_id: string;
|
|
256
|
-
/** Conversation that contained the message. */
|
|
257
|
-
conversation_id?: string | null;
|
|
258
|
-
}
|
|
259
|
-
/** `app.status_changed`: a turn started, finished or failed. */
|
|
260
|
-
export interface AppStatusChanged extends BranchScoped {
|
|
261
|
-
/** The new state; null clears it. */
|
|
262
|
-
status: AppStatus | null;
|
|
263
|
-
}
|
|
264
|
-
/** `preview.navigation_requested`: show this page of the app in the preview. */
|
|
265
|
-
export interface PreviewNavigationRequested extends BranchScoped {
|
|
266
|
-
/** App path to show. */
|
|
267
|
-
path: string;
|
|
268
|
-
/** Navigate even when the user has moved away from the page. */
|
|
269
|
-
force: boolean;
|
|
270
|
-
}
|
|
271
|
-
/** A queued builder request. */
|
|
272
|
-
export interface QueueItem {
|
|
273
|
-
/** Queue item identifier. */
|
|
274
|
-
id?: string;
|
|
275
|
-
/** User-authored request text. */
|
|
276
|
-
content?: string;
|
|
277
|
-
/** Creation timestamp. */
|
|
278
|
-
created_at?: string;
|
|
279
|
-
/** Branch the request belongs to. */
|
|
280
|
-
branch_id?: string | null;
|
|
281
|
-
}
|
|
282
|
-
/** `queue.updated`: the whole prompt queue, replacing the previous one. */
|
|
283
|
-
export interface QueueUpdated extends BranchScoped {
|
|
284
|
-
/** Pending items. */
|
|
285
|
-
items?: QueueItem[];
|
|
286
|
-
/** Whether queue processing is paused. */
|
|
287
|
-
is_paused?: boolean;
|
|
288
|
-
/** Identifier of the item just processed, when supplied. */
|
|
289
|
-
processed_item_id?: string | null;
|
|
290
|
-
}
|
|
291
|
-
/** `task.progressed`: progress of a long-running tool. */
|
|
292
|
-
export interface TaskProgressed extends BranchScoped {
|
|
293
|
-
/** Associated tool call. */
|
|
294
|
-
tool_call_id?: string | null;
|
|
295
|
-
/** Associated chat message. */
|
|
296
|
-
message_id?: string | null;
|
|
297
|
-
/** Task lifecycle event, e.g. `task_progress`. */
|
|
298
|
-
event_type?: string | null;
|
|
299
|
-
/** Numeric progress only; diagnostic text is withheld. */
|
|
300
|
-
progress?: {
|
|
301
|
-
/** Completed work units. */
|
|
302
|
-
current?: number | null;
|
|
303
|
-
/** Total work units, when known. */
|
|
304
|
-
total?: number | null;
|
|
305
|
-
/** Producer-supplied percentage. */
|
|
306
|
-
percentage?: number | null;
|
|
307
|
-
} | null;
|
|
308
|
-
}
|
|
309
|
-
/** `image.resolved`: a generated image finished or failed. Replace its `placeholder_url` wherever it appears. */
|
|
310
|
-
export type ImageResolved = ToolMediaResult;
|
|
311
|
-
/** Mapping of public event names to their payloads. */
|
|
312
|
-
export interface PlatformEventMap {
|
|
313
|
-
/** A chat message was added or replaced. */
|
|
314
|
-
"message.updated": MessageUpdated;
|
|
315
|
-
/** A chat message was removed or hidden. */
|
|
316
|
-
"message.removed": MessageRemoved;
|
|
317
|
-
/** The builder started, finished or failed a turn. */
|
|
318
|
-
"app.status_changed": AppStatusChanged;
|
|
319
|
-
/** Reload the app preview. */
|
|
320
|
-
"preview.reload_requested": BranchScoped;
|
|
321
|
-
/** Show a page of the app in the preview. */
|
|
322
|
-
"preview.navigation_requested": PreviewNavigationRequested;
|
|
323
|
-
/** The whole prompt queue. */
|
|
324
|
-
"queue.updated": QueueUpdated;
|
|
325
|
-
/** Progress of a long-running tool. */
|
|
326
|
-
"task.progressed": TaskProgressed;
|
|
327
|
-
/** A generated image finished or failed. */
|
|
328
|
-
"image.resolved": ImageResolved;
|
|
329
|
-
/** The conversation was rewritten (undo, restore, sync). On main, the SDK rejoins for a fresh snapshot. */
|
|
330
|
-
"conversation.changed": BranchScoped;
|
|
331
|
-
/** The app's files changed outside a chat turn. Re-read them. */
|
|
332
|
-
"files.changed": BranchScoped;
|
|
333
|
-
/** A branch was deleted. */
|
|
334
|
-
"branch.deleted": BranchScoped;
|
|
335
|
-
/** The imported app's repository changed. */
|
|
336
|
-
"repository.changed": BranchScoped;
|
|
337
|
-
/** The imported app's pull request changed. */
|
|
338
|
-
"pull_request.changed": BranchScoped;
|
|
339
|
-
}
|
|
340
|
-
/** Ordered delivery of one public event. */
|
|
1
|
+
import type { Message, QueueState, ServerEventMap, Snapshot } from "./builder.events.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* Maps each live event name to the type of its `data` payload.
|
|
4
|
+
*
|
|
5
|
+
* Generated from the service's AsyncAPI document, so it covers every app event the service sends.
|
|
6
|
+
* The client handles the session events `app.snapshot`, `session.ended` and `room.*` itself, and
|
|
7
|
+
* reports them through `onSnapshot` and `onError` instead.
|
|
8
|
+
*/
|
|
9
|
+
export type PlatformEventMap = {
|
|
10
|
+
[K in keyof ServerEventMap as K extends "app.snapshot" | "session.ended" | `room.${string}` ? never : K]: ServerEventMap[K];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* One live event for a subscribed app.
|
|
14
|
+
*
|
|
15
|
+
* Check `type` to narrow `data` to that event's payload. A key missing from `data` means the value
|
|
16
|
+
* is unchanged, and an explicit `null` clears it. For every event and its payload, see
|
|
17
|
+
* [Socket messages](/developers/references/apps-api/sections/socket-messages).
|
|
18
|
+
*
|
|
19
|
+
* An event added to the service after this version of the SDK arrives with `type: "unknown"`, its
|
|
20
|
+
* name in `name` and an unchecked `data`, so check a field before using it. After you upgrade, it
|
|
21
|
+
* arrives under its own `type`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Narrow an event by type
|
|
26
|
+
* function onEvent(event: PlatformEvent) {
|
|
27
|
+
* if (event.type === "message.updated") {
|
|
28
|
+
* const { message } = event.data;
|
|
29
|
+
* console.log(`Message ${message.id} changed`);
|
|
30
|
+
* }
|
|
31
|
+
* if (event.type === "unknown" && event.name === "app.renamed" && typeof event.data.name === "string") {
|
|
32
|
+
* console.log(`App renamed to ${event.data.name}`);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
341
37
|
export type PlatformEvent = {
|
|
342
38
|
[K in keyof PlatformEventMap]: {
|
|
343
|
-
/**
|
|
39
|
+
/** Event name. Narrows the type of `data`. */
|
|
344
40
|
type: K;
|
|
345
|
-
/**
|
|
41
|
+
/** ID of the app the event belongs to. */
|
|
346
42
|
appId: string;
|
|
347
|
-
/** Event payload.
|
|
43
|
+
/** Event payload. */
|
|
348
44
|
data: PlatformEventMap[K];
|
|
349
45
|
};
|
|
350
|
-
}[keyof PlatformEventMap]
|
|
351
|
-
/** An
|
|
352
|
-
|
|
353
|
-
/**
|
|
46
|
+
}[keyof PlatformEventMap] | {
|
|
47
|
+
/** An event this version of the SDK doesn't know. */
|
|
48
|
+
type: "unknown";
|
|
49
|
+
/** The event's name on the socket. */
|
|
50
|
+
name: string;
|
|
51
|
+
/** ID of the app the event belongs to. */
|
|
52
|
+
appId: string;
|
|
53
|
+
/** Event payload, not checked by the SDK. */
|
|
54
|
+
data: Record<string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* An app's current state.
|
|
58
|
+
*
|
|
59
|
+
* Arrives after every join and rejoin, and after a rewrite of the main conversation. Replace
|
|
60
|
+
* everything you hold for the app with it. It holds only the last 50 messages.
|
|
61
|
+
*
|
|
62
|
+
* Its fields are the `data` of [`app.snapshot`](/developers/references/apps-api/sections/socket-messages#app-snapshot),
|
|
63
|
+
* plus `room`.
|
|
64
|
+
*/
|
|
65
|
+
export interface PlatformSnapshot extends Omit<Snapshot, "queue"> {
|
|
66
|
+
/** The app's room, `/apps/{app_id}`. */
|
|
354
67
|
room: string;
|
|
355
|
-
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
items: QueueItem[];
|
|
366
|
-
/** Whether queue processing is paused. */
|
|
367
|
-
is_paused: boolean;
|
|
368
|
-
}
|
|
68
|
+
/** The main branch's prompt queue. Missing when the server sends none. */
|
|
69
|
+
queue?: QueueState;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One tool call in a message's `tool_calls`. Checking `name` narrows it to that tool's call and
|
|
73
|
+
* `OtherToolCall`, which covers tools the SDK doesn't know, so check a field with `in` before using it.
|
|
74
|
+
*/
|
|
75
|
+
export type ToolCall = NonNullable<Message["tool_calls"]>[number];
|
|
76
|
+
/** Why a safety guard parked a tool call for approval. Check `guard` to narrow it. */
|
|
77
|
+
export type GuardApproval = NonNullable<ToolCall["approval"]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BuilderSocket } from "./builder-socket.js";
|
|
2
2
|
/** @internal */
|
|
3
|
-
export function createBuilder(
|
|
3
|
+
export function createBuilder() {
|
|
4
4
|
return {
|
|
5
|
-
init(options) { return new BuilderSocket(
|
|
5
|
+
init(options) { return new BuilderSocket(options); },
|
|
6
6
|
};
|
|
7
7
|
}
|