@base44-preview/sdk 0.8.52-pr.286.2dbb896 → 0.8.52-pr.286.be667a9
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/platform/client/index.d.ts +1 -1
- package/dist/platform/client/modules/builder-protocol.d.ts +8 -4
- package/dist/platform/client/modules/builder-protocol.js +16 -15
- package/dist/platform/client/modules/builder-socket.d.ts +2 -1
- package/dist/platform/client/modules/builder-socket.js +29 -18
- package/dist/platform/client/modules/builder.events.types.d.ts +162 -158
- package/dist/platform/client/modules/builder.types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,4 +4,4 @@ export { PlatformSocketError } from "./errors.js";
|
|
|
4
4
|
export type { PlatformSocketErrorCode } from "./errors.types.js";
|
|
5
5
|
export type { PlatformClientOptions } from "./client.types.js";
|
|
6
6
|
export type { BuilderModule, BuilderInitOptions, BuilderSession, PlatformSubscription, SubscriptionOptions } from "./modules/builder.types.js";
|
|
7
|
-
export type {
|
|
7
|
+
export type { AppStatus, AppStatusChanged, BranchScoped, ChatMessage, ImageResolved, MessageParams, MessageRemoved, MessageUpdated, PlatformEvent, PlatformEventMap, PreviewNavigationRequested, QueueItem, QueueUpdated, Snapshot, TaskProgressed, ToolArguments, ToolCall, ToolDisplay, ToolGuardApproval, ToolMediaArguments, ToolMediaResult, ToolPackageArguments, ToolPackageOperation, ToolPlanArguments, ToolPlanUpdate, ToolPrdArguments, ToolQuestion, ToolQuestionAnswer, ToolQuestionArguments, ToolQuestionInput, ToolQuestionOption, ToolSecretArguments, ToolSecretField, } from "./modules/builder.events.types.js";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { PlatformEvent, PlatformEventMap, Snapshot } from "./builder.events.types.js";
|
|
2
|
-
export declare const eventNames: readonly ["
|
|
3
|
-
/**
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const eventNames: readonly ["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"];
|
|
3
|
+
/** Notices that name an app room, by the error code each one reports. */
|
|
4
|
+
export declare const roomNotices: {
|
|
5
|
+
readonly "room.access_denied": "access_denied";
|
|
6
|
+
readonly "room.access_revoked": "access_revoked";
|
|
7
|
+
readonly "room.snapshot_unavailable": "snapshot_unavailable";
|
|
8
|
+
};
|
|
5
9
|
export declare const appPattern: RegExp;
|
|
6
10
|
export declare const roomFor: (appId: string) => string;
|
|
7
11
|
export declare function object(value: unknown): Record<string, unknown>;
|
|
8
|
-
export declare function string(value: unknown): string;
|
|
9
12
|
export declare function appFromRoom(value: unknown): string | undefined;
|
|
13
|
+
/** Every event is `{room, data}`; payload schemas are the service's, so only the envelope is validated. */
|
|
10
14
|
export declare function decode(type: keyof PlatformEventMap, appId: string, raw: unknown): PlatformEvent;
|
|
11
15
|
export declare function decodeSnapshot(raw: unknown): Snapshot;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
export const eventNames = [
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const eventNames = [
|
|
2
|
+
"message.updated", "message.removed", "app.status_changed", "preview.reload_requested",
|
|
3
|
+
"preview.navigation_requested", "queue.updated", "task.progressed", "image.resolved",
|
|
4
|
+
"conversation.changed", "files.changed", "branch.deleted", "repository.changed", "pull_request.changed",
|
|
5
|
+
];
|
|
6
|
+
/** Notices that name an app room, by the error code each one reports. */
|
|
7
|
+
export const roomNotices = {
|
|
8
|
+
"room.access_denied": "access_denied",
|
|
9
|
+
"room.access_revoked": "access_revoked",
|
|
10
|
+
"room.snapshot_unavailable": "snapshot_unavailable",
|
|
11
|
+
};
|
|
4
12
|
export const appPattern = /^[a-f0-9]{24}$/;
|
|
5
13
|
export const roomFor = (appId) => `/apps/${appId}`;
|
|
6
14
|
export function object(value) {
|
|
@@ -8,25 +16,18 @@ export function object(value) {
|
|
|
8
16
|
throw new Error("Invalid frame");
|
|
9
17
|
return value;
|
|
10
18
|
}
|
|
11
|
-
export function string(value) {
|
|
12
|
-
if (typeof value !== "string" || !value)
|
|
13
|
-
throw new Error("Invalid string");
|
|
14
|
-
return value;
|
|
15
|
-
}
|
|
16
19
|
export function appFromRoom(value) {
|
|
17
20
|
return typeof value === "string" && /^\/apps\/[a-f0-9]{24}$/.test(value) ? value.slice(6) : undefined;
|
|
18
21
|
}
|
|
22
|
+
/** Every event is `{room, data}`; payload schemas are the service's, so only the envelope is validated. */
|
|
19
23
|
export function decode(type, appId, raw) {
|
|
20
|
-
|
|
21
|
-
const wrapped = type === "update_model" || type === "task_update" || type === "image_ready";
|
|
22
|
-
const data = wrapped ? object(JSON.parse(string(frame.data))) : frame;
|
|
23
|
-
// Payload schemas are owned by the service; only decode/validate the transport envelope here.
|
|
24
|
-
return { type, appId, data };
|
|
24
|
+
return { type, appId, data: object(object(raw).data) };
|
|
25
25
|
}
|
|
26
26
|
export function decodeSnapshot(raw) {
|
|
27
27
|
const frame = object(raw);
|
|
28
|
-
|
|
28
|
+
const data = object(frame.data);
|
|
29
|
+
if (!appFromRoom(frame.room) || !Array.isArray(data.messages) || (data.status !== null && typeof data.status !== "object")) {
|
|
29
30
|
throw new Error("Invalid snapshot");
|
|
30
31
|
}
|
|
31
|
-
return frame;
|
|
32
|
+
return { room: frame.room, status: data.status, messages: data.messages };
|
|
32
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { io } from "socket.io-client";
|
|
2
2
|
import { PlatformSocketError } from "../errors.js";
|
|
3
|
-
import { appFromRoom, appPattern, decode, decodeSnapshot, eventNames, object,
|
|
3
|
+
import { appFromRoom, appPattern, decode, decodeSnapshot, eventNames, object, roomFor, roomNotices } from "./builder-protocol.js";
|
|
4
4
|
import { notify, Subscription } from "./builder-subscription.js";
|
|
5
5
|
const MAX_DENIAL_RETRIES = 5;
|
|
6
6
|
/** @internal */
|
|
@@ -40,7 +40,7 @@ export class BuilderSocket {
|
|
|
40
40
|
});
|
|
41
41
|
this.socket.on("connect_error", (error) => this.refused(error));
|
|
42
42
|
this.socket.io.on("reconnect_failed", () => this.connectionError(new PlatformSocketError("connection_failed")));
|
|
43
|
-
this.socket.on("
|
|
43
|
+
this.socket.on("app.snapshot", (raw) => {
|
|
44
44
|
var _a;
|
|
45
45
|
try {
|
|
46
46
|
const snapshot = decodeSnapshot(raw);
|
|
@@ -50,17 +50,23 @@ export class BuilderSocket {
|
|
|
50
50
|
this.protocolError(raw);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
this.socket.on("
|
|
53
|
+
this.socket.on("session.ended", (raw) => this.sessionEnded(raw));
|
|
54
|
+
for (const [name, code] of Object.entries(roomNotices))
|
|
55
|
+
this.socket.on(name, (raw) => this.roomNotice(code, raw));
|
|
54
56
|
for (const type of eventNames)
|
|
55
57
|
this.socket.on(type, (raw) => {
|
|
56
|
-
var _a;
|
|
57
58
|
try {
|
|
58
59
|
const appId = appFromRoom(object(raw).room);
|
|
59
60
|
if (!appId)
|
|
60
61
|
throw new Error("Invalid app");
|
|
61
|
-
|
|
62
|
+
const event = decode(type, appId, raw);
|
|
63
|
+
const subscription = this.subscriptions.get(appId);
|
|
64
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.event(event);
|
|
65
|
+
// The server does not resend a snapshot after a rewrite of main: rejoining asks for one.
|
|
66
|
+
if (subscription && event.type === "conversation.changed" && event.data.branch_id == null)
|
|
67
|
+
this.join(subscription);
|
|
62
68
|
}
|
|
63
|
-
catch (
|
|
69
|
+
catch (_a) {
|
|
64
70
|
this.protocolError(raw);
|
|
65
71
|
}
|
|
66
72
|
});
|
|
@@ -199,19 +205,24 @@ export class BuilderSocket {
|
|
|
199
205
|
if (!this.closed)
|
|
200
206
|
notify(this.options.onError, error);
|
|
201
207
|
}
|
|
202
|
-
|
|
208
|
+
sessionEnded(raw) {
|
|
203
209
|
try {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
const reason = object(object(raw).data).reason;
|
|
211
|
+
if (reason !== "expired" && reason !== "replaced")
|
|
212
|
+
throw new Error("Unknown reason");
|
|
213
|
+
// The server disconnects next; the disconnect handler renews or stops.
|
|
214
|
+
this.token = undefined;
|
|
215
|
+
this.ending = reason === "expired" ? "session_expired" : "session_replaced";
|
|
216
|
+
}
|
|
217
|
+
catch (_a) {
|
|
218
|
+
this.protocolError(raw);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
roomNotice(code, raw) {
|
|
222
|
+
try {
|
|
223
|
+
const appId = appFromRoom(object(raw).room);
|
|
224
|
+
if (!appId)
|
|
225
|
+
throw new Error("Invalid app");
|
|
215
226
|
const subscription = this.subscriptions.get(appId);
|
|
216
227
|
if (code === "snapshot_unavailable")
|
|
217
228
|
subscription === null || subscription === void 0 ? void 0 : subscription.warn(code);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export interface
|
|
1
|
+
/** Activity a file, execution or entity tool declared public. */
|
|
2
|
+
export interface ToolDisplay {
|
|
3
3
|
/** Changed file paths for a file operation. Source bodies and diffs are never included. */
|
|
4
4
|
file_paths?: string[];
|
|
5
5
|
/** Whether a file write intentionally used empty content. */
|
|
@@ -13,75 +13,74 @@ export interface ToolDisplayProjection {
|
|
|
13
13
|
/** Number of records affected when supplied by the producer. */
|
|
14
14
|
record_count?: number;
|
|
15
15
|
}
|
|
16
|
-
/** A
|
|
16
|
+
/** A selectable answer to a builder question. */
|
|
17
17
|
export interface ToolQuestionOption {
|
|
18
18
|
/** Visible option label. */
|
|
19
|
-
label
|
|
19
|
+
label?: string;
|
|
20
20
|
}
|
|
21
|
-
/** A
|
|
21
|
+
/** A builder question. Image/HTML source and private design context are excluded. */
|
|
22
22
|
export interface ToolQuestion {
|
|
23
23
|
/** Visible question text. */
|
|
24
24
|
question?: string;
|
|
25
|
-
/**
|
|
25
|
+
/** Question category. */
|
|
26
26
|
type?: string;
|
|
27
27
|
/** Optional visible supporting text. */
|
|
28
28
|
description?: string;
|
|
29
29
|
/** Whether more than one answer may be selected. */
|
|
30
30
|
multi_select?: boolean;
|
|
31
|
-
/**
|
|
31
|
+
/** Plan section the question covers. */
|
|
32
32
|
covers?: string;
|
|
33
|
-
/**
|
|
34
|
-
options?: ToolQuestionOption[];
|
|
33
|
+
/** Selectable options; a bare string option is its label. */
|
|
34
|
+
options?: (ToolQuestionOption | string)[];
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
36
|
+
/** `ask_clarifying_questions` and `ask_plan_questions` arguments. */
|
|
37
37
|
export interface ToolQuestionArguments {
|
|
38
|
-
/** Questions presented
|
|
39
|
-
questions
|
|
38
|
+
/** Questions presented to the user. */
|
|
39
|
+
questions?: ToolQuestion[];
|
|
40
40
|
}
|
|
41
41
|
/** A requested secret field. The secret value is never sent over the socket. */
|
|
42
42
|
export interface ToolSecretField {
|
|
43
43
|
/** Requested secret name. */
|
|
44
|
-
secretName
|
|
44
|
+
secretName?: string;
|
|
45
45
|
/** Optional explanation of where to obtain it. */
|
|
46
46
|
description?: string;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
48
|
+
/** `set_secrets` arguments. */
|
|
49
49
|
export interface ToolSecretArguments {
|
|
50
50
|
/** Requested secret fields. */
|
|
51
|
-
secrets_schema
|
|
51
|
+
secrets_schema?: ToolSecretField[];
|
|
52
52
|
}
|
|
53
|
-
/** A
|
|
53
|
+
/** A package operation. Versions and package-manager output are excluded. */
|
|
54
54
|
export interface ToolPackageOperation {
|
|
55
55
|
/** Package name. */
|
|
56
|
-
name
|
|
56
|
+
name?: string;
|
|
57
57
|
/** Requested package operation. */
|
|
58
58
|
action?: string;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/** `install_npm_package` arguments. */
|
|
61
61
|
export interface ToolPackageArguments {
|
|
62
62
|
/** Requested package operations. */
|
|
63
|
-
packages
|
|
63
|
+
packages?: ToolPackageOperation[];
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
65
|
+
/** An add-only builder plan update. */
|
|
66
66
|
export interface ToolPlanUpdate {
|
|
67
|
-
/**
|
|
67
|
+
/** Update action. */
|
|
68
68
|
action?: string;
|
|
69
69
|
/** Plan section key. */
|
|
70
70
|
section?: string;
|
|
71
71
|
/** Optional user-facing section label. */
|
|
72
72
|
section_label?: string;
|
|
73
|
-
/**
|
|
73
|
+
/** Plan point. */
|
|
74
74
|
text?: string;
|
|
75
75
|
}
|
|
76
|
-
/**
|
|
76
|
+
/** `update_plan` arguments. */
|
|
77
77
|
export interface ToolPlanArguments {
|
|
78
78
|
/** Plan updates in their emitted order. */
|
|
79
79
|
updates?: ToolPlanUpdate[];
|
|
80
80
|
/** Base plan sections the builder considers sufficiently specified. */
|
|
81
81
|
sections_with_enough?: string[];
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* user's own spec; in plan mode the message `content` beside it can be empty. */
|
|
83
|
+
/** `generate_prd` arguments: the user's own plan. In plan mode the message `content` beside it can be empty. */
|
|
85
84
|
export interface ToolPrdArguments {
|
|
86
85
|
/** App or feature name. */
|
|
87
86
|
app_name?: string;
|
|
@@ -102,45 +101,47 @@ export interface ToolPrdArguments {
|
|
|
102
101
|
/** Engine settled in planning, for game plans. */
|
|
103
102
|
game_engine?: string;
|
|
104
103
|
}
|
|
105
|
-
/**
|
|
104
|
+
/** Image, game-image and video generation arguments. */
|
|
106
105
|
export interface ToolMediaArguments {
|
|
107
106
|
/** Visible media label. */
|
|
108
107
|
label?: string;
|
|
109
108
|
/** Requested image or video aspect ratio. */
|
|
110
109
|
aspect_ratio?: string;
|
|
111
110
|
}
|
|
112
|
-
/**
|
|
111
|
+
/** The public arguments of a tool that declares them; narrow by the tool call's `name`. */
|
|
112
|
+
export type ToolArguments = ToolQuestionArguments | ToolSecretArguments | ToolPackageArguments | ToolPlanArguments | ToolPrdArguments | ToolMediaArguments;
|
|
113
|
+
/** Generated-media state. Raw generation prompts and IDs are never included. */
|
|
113
114
|
export interface ToolMediaResult {
|
|
114
|
-
/**
|
|
115
|
-
placeholder_url
|
|
115
|
+
/** Placeholder URL, used to associate an `image.resolved` event with this tool. */
|
|
116
|
+
placeholder_url?: string;
|
|
116
117
|
/** Current media-generation status. */
|
|
117
|
-
status
|
|
118
|
-
/**
|
|
119
|
-
image_url
|
|
118
|
+
status?: "pending" | "completed" | "failed";
|
|
119
|
+
/** Generated asset URL, once available. */
|
|
120
|
+
image_url?: string | null;
|
|
120
121
|
}
|
|
121
|
-
/**
|
|
122
|
+
/** An answer to a clarifying question. Secret-form input is never included. */
|
|
122
123
|
export interface ToolQuestionAnswer {
|
|
123
124
|
/** Zero-based question index. */
|
|
124
125
|
question_index?: number;
|
|
125
|
-
/**
|
|
126
|
+
/** Label selected for a single-select question. */
|
|
127
|
+
selected_label?: string;
|
|
128
|
+
/** Labels selected for a multi-select question. */
|
|
126
129
|
selected_labels?: string[];
|
|
127
130
|
/** User-provided free-text answer. Structural filtering does not redact prose. */
|
|
128
131
|
custom_text?: string;
|
|
129
132
|
}
|
|
130
|
-
/**
|
|
133
|
+
/** Clarifying-question answers. */
|
|
131
134
|
export interface ToolQuestionInput {
|
|
132
135
|
/** Answers supplied to the question card. */
|
|
133
|
-
answers
|
|
136
|
+
answers?: ToolQuestionAnswer[];
|
|
134
137
|
}
|
|
135
|
-
/** Fixed reviewed completion text. Raw tool results and errors are never included. */
|
|
136
|
-
export type ToolOutcome = "Secret configuration completed." | "Package installation completed." | "Plan updated.";
|
|
137
138
|
/** Why a safety guard parked a call for approval. Only present while the call waits. */
|
|
138
139
|
export interface ToolGuardApproval {
|
|
139
140
|
/** Guard identifier, e.g. `exec_tool_send_email` or `bash_approval`. */
|
|
140
141
|
guard: string;
|
|
141
|
-
/** Human-readable reason
|
|
142
|
+
/** Human-readable reason, for guards whose reason never quotes input (not shell commands). */
|
|
142
143
|
reason?: string;
|
|
143
|
-
/**
|
|
144
|
+
/** The details the guard declares public; commands and record data are never included. */
|
|
144
145
|
details?: {
|
|
145
146
|
/** Entity method the code calls, e.g. `delete`. */
|
|
146
147
|
method?: string;
|
|
@@ -158,61 +159,38 @@ export interface ToolGuardApproval {
|
|
|
158
159
|
inspection_failed?: boolean;
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
|
-
/**
|
|
162
|
-
export type ToolResult = ToolOutcome | ToolMediaResult | ToolGuardApproval;
|
|
163
|
-
/** Public progress of an existing builder tool. */
|
|
162
|
+
/** Public progress of a builder tool call. Only what the tool and its guard declare public is present. */
|
|
164
163
|
export interface ToolCall {
|
|
165
|
-
/** Stable tool call identifier
|
|
164
|
+
/** Stable tool call identifier. */
|
|
166
165
|
id?: string;
|
|
167
|
-
/** Tool name
|
|
166
|
+
/** Tool name. */
|
|
168
167
|
name?: string;
|
|
169
168
|
/** Current execution state. */
|
|
170
169
|
status?: "running" | "success" | "error" | "stopped" | "waiting_for_user_input";
|
|
171
170
|
/** Whether the tool needs a user response through the partner backend. */
|
|
172
171
|
requires_user_input?: boolean;
|
|
173
|
-
/** Whether the builder auto-approved the
|
|
174
|
-
auto_approved?: boolean
|
|
175
|
-
/** Whether the
|
|
172
|
+
/** Whether the builder auto-approved the operation. */
|
|
173
|
+
auto_approved?: boolean;
|
|
174
|
+
/** Whether the mutation was applied. */
|
|
176
175
|
mutation_applied?: boolean | null;
|
|
177
|
-
/**
|
|
176
|
+
/** Kind of response a parked call waits for. */
|
|
178
177
|
waiting_on?: {
|
|
179
178
|
/** Kind of response expected. */
|
|
180
|
-
kind?: "approval" | "choice" | "input"
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
arguments_string?: string;
|
|
188
|
-
/** Reviewed activity metadata for file, execution, or entity tools. */
|
|
189
|
-
display_projection?: ToolDisplayProjection;
|
|
190
|
-
/** Reviewed clarifying-question answers only. */
|
|
179
|
+
kind?: "approval" | "choice" | "input";
|
|
180
|
+
};
|
|
181
|
+
/** The tool's public arguments; absent for tools that declare none and for partial streaming arguments. */
|
|
182
|
+
arguments?: ToolArguments;
|
|
183
|
+
/** What a file, execution or entity tool touched. */
|
|
184
|
+
display?: ToolDisplay;
|
|
185
|
+
/** Clarifying-question answers. */
|
|
191
186
|
user_input?: ToolQuestionInput;
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
-
/** Existing message identifier; replace a message with the same identifier. */
|
|
198
|
-
id?: string;
|
|
199
|
-
/** Public message author category. System messages are never delivered. */
|
|
200
|
-
role?: "user" | "assistant";
|
|
201
|
-
/** Generated or user-authored text. Structural filtering is not prose redaction. */
|
|
202
|
-
content?: string | null;
|
|
203
|
-
/** Public tool progress with optional reviewed interaction details. */
|
|
204
|
-
tool_calls?: ToolCall[] | null;
|
|
205
|
-
/** Message timestamp, without author identity. */
|
|
206
|
-
metadata?: {
|
|
207
|
-
/** Existing timestamp string. */
|
|
208
|
-
created_date?: string | null;
|
|
209
|
-
} | null;
|
|
210
|
-
/** Existing checkpoint reference; mutations remain on the partner backend. */
|
|
211
|
-
checkpoint_id?: string | null;
|
|
212
|
-
/** Reviewed scalar message parameters. */
|
|
213
|
-
additional_message_params?: MessageParams;
|
|
187
|
+
/** Generated media, once the call is not waiting on a guard: the image tool's state, or a URL alone
|
|
188
|
+
* (a game asset's placeholder, which `image.resolved` replaces, or a finished video). */
|
|
189
|
+
results?: ToolMediaResult | string;
|
|
190
|
+
/** A parked call's guard, and its reason and details where the guard declares them. */
|
|
191
|
+
approval?: ToolGuardApproval;
|
|
214
192
|
}
|
|
215
|
-
/**
|
|
193
|
+
/** Scalar parameters a chat UI needs while a turn runs. */
|
|
216
194
|
export interface MessageParams {
|
|
217
195
|
/** Identifier the sending client attached, to match its optimistic message. */
|
|
218
196
|
client_creation_id?: string;
|
|
@@ -225,67 +203,93 @@ export interface MessageParams {
|
|
|
225
203
|
/** System message category. */
|
|
226
204
|
system_message_type?: string;
|
|
227
205
|
}
|
|
206
|
+
/** A public chat message. Replace the message with the same `id` as a whole. */
|
|
207
|
+
export interface ChatMessage {
|
|
208
|
+
/** Message identifier. */
|
|
209
|
+
id?: string;
|
|
210
|
+
/** Author category. System and hidden messages are never delivered. */
|
|
211
|
+
role?: "user" | "assistant";
|
|
212
|
+
/** Message text; structured content is withheld. Structural filtering is not prose redaction. */
|
|
213
|
+
content?: string | null;
|
|
214
|
+
/** Public tool progress. */
|
|
215
|
+
tool_calls?: ToolCall[] | null;
|
|
216
|
+
/** Message timestamp, without author identity. */
|
|
217
|
+
metadata?: {
|
|
218
|
+
/** ISO timestamp string. */
|
|
219
|
+
created_date?: string;
|
|
220
|
+
};
|
|
221
|
+
/** Checkpoint reference; mutations remain on the partner backend. */
|
|
222
|
+
checkpoint_id?: string | null;
|
|
223
|
+
/** Scalar message parameters. */
|
|
224
|
+
additional_message_params?: MessageParams;
|
|
225
|
+
}
|
|
228
226
|
/** Public builder state, without error diagnostics or billing context. */
|
|
229
227
|
export interface AppStatus {
|
|
230
228
|
/** Current builder state. */
|
|
231
229
|
state?: "ready" | "processing" | "error";
|
|
232
|
-
/**
|
|
230
|
+
/** State timestamp. */
|
|
233
231
|
last_updated_date?: string | null;
|
|
234
232
|
}
|
|
235
|
-
/**
|
|
236
|
-
export interface
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
|
|
233
|
+
/** Branch scope carried by app events. Null or absent is the main branch. */
|
|
234
|
+
export interface BranchScoped {
|
|
235
|
+
/** Branch the change belongs to; null is main. */
|
|
236
|
+
branch_id?: string | null;
|
|
237
|
+
}
|
|
238
|
+
/** `message.updated`: a chat message was added or replaced. */
|
|
239
|
+
export interface MessageUpdated extends BranchScoped {
|
|
240
|
+
/** The whole message; replace the one with the same `id`. */
|
|
241
|
+
message: ChatMessage;
|
|
242
|
+
/** Conversation containing the message. */
|
|
243
|
+
conversation_id?: string | null;
|
|
244
|
+
}
|
|
245
|
+
/** `message.removed`: a message was removed or hidden. An `id` the viewer never saw is a no-op. */
|
|
246
|
+
export interface MessageRemoved extends BranchScoped {
|
|
247
|
+
/** Identifier of the message to remove. */
|
|
248
|
+
message_id: string;
|
|
249
|
+
/** Conversation that contained the message. */
|
|
250
|
+
conversation_id?: string | null;
|
|
251
|
+
}
|
|
252
|
+
/** `app.status_changed`: a turn started, finished or failed. */
|
|
253
|
+
export interface AppStatusChanged extends BranchScoped {
|
|
254
|
+
/** The new state; null clears it. */
|
|
255
|
+
status: AppStatus | null;
|
|
256
|
+
}
|
|
257
|
+
/** `preview.navigation_requested`: show this page of the app in the preview. */
|
|
258
|
+
export interface PreviewNavigationRequested extends BranchScoped {
|
|
259
|
+
/** App path to show. */
|
|
260
|
+
path: string;
|
|
261
|
+
/** Navigate even when the user has moved away from the page. */
|
|
262
|
+
force: boolean;
|
|
251
263
|
}
|
|
252
|
-
/**
|
|
264
|
+
/** A queued builder request. */
|
|
253
265
|
export interface QueueItem {
|
|
254
|
-
/**
|
|
255
|
-
id
|
|
266
|
+
/** Queue item identifier. */
|
|
267
|
+
id?: string;
|
|
256
268
|
/** User-authored request text. */
|
|
257
|
-
content
|
|
258
|
-
/**
|
|
259
|
-
created_at
|
|
260
|
-
/**
|
|
269
|
+
content?: string;
|
|
270
|
+
/** Creation timestamp. */
|
|
271
|
+
created_at?: string;
|
|
272
|
+
/** Branch the request belongs to. */
|
|
261
273
|
branch_id?: string | null;
|
|
262
274
|
}
|
|
263
|
-
/**
|
|
264
|
-
export interface
|
|
265
|
-
/**
|
|
266
|
-
|
|
267
|
-
/** App owning this queue. */
|
|
268
|
-
app_id: string;
|
|
269
|
-
/** Existing branch scope. */
|
|
270
|
-
branch_id?: string | null;
|
|
271
|
-
/** Current pending items. */
|
|
272
|
-
items: QueueItem[];
|
|
275
|
+
/** `queue.updated`: the whole prompt queue, replacing the previous one. */
|
|
276
|
+
export interface QueueUpdated extends BranchScoped {
|
|
277
|
+
/** Pending items. */
|
|
278
|
+
items?: QueueItem[];
|
|
273
279
|
/** Whether queue processing is paused. */
|
|
274
|
-
is_paused
|
|
280
|
+
is_paused?: boolean;
|
|
275
281
|
/** Identifier of the item just processed, when supplied. */
|
|
276
282
|
processed_item_id?: string | null;
|
|
277
283
|
}
|
|
278
|
-
/**
|
|
279
|
-
export interface
|
|
280
|
-
/** Existing task lifecycle event. */
|
|
281
|
-
event_type: "task_started" | "task_progress" | "task_completed" | "task_failed" | "task_cancelled";
|
|
284
|
+
/** `task.progressed`: progress of a long-running tool. */
|
|
285
|
+
export interface TaskProgressed extends BranchScoped {
|
|
282
286
|
/** Associated tool call. */
|
|
283
287
|
tool_call_id?: string | null;
|
|
284
288
|
/** Associated chat message. */
|
|
285
289
|
message_id?: string | null;
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
/** Numeric progress only; diagnostic
|
|
290
|
+
/** Task lifecycle event, e.g. `task_progress`. */
|
|
291
|
+
event_type?: string | null;
|
|
292
|
+
/** Numeric progress only; diagnostic text is withheld. */
|
|
289
293
|
progress?: {
|
|
290
294
|
/** Completed work units. */
|
|
291
295
|
current?: number | null;
|
|
@@ -295,49 +299,49 @@ export interface TaskUpdate {
|
|
|
295
299
|
percentage?: number | null;
|
|
296
300
|
} | null;
|
|
297
301
|
}
|
|
298
|
-
/**
|
|
299
|
-
export
|
|
300
|
-
|
|
301
|
-
placeholder_url: string;
|
|
302
|
-
/** Existing generation state. */
|
|
303
|
-
status: "pending" | "completed" | "failed";
|
|
304
|
-
/** Resolved image URL, or null when unavailable. */
|
|
305
|
-
image_url?: string | null;
|
|
306
|
-
}
|
|
307
|
-
/** Invalidation notice. A main-conversation `conversation_changed` is followed by a snapshot. */
|
|
308
|
-
export interface Directive {
|
|
309
|
-
/** Canonical app room. */
|
|
310
|
-
room: string;
|
|
311
|
-
/** Public invalidation category. */
|
|
312
|
-
type: "conversation_changed" | "app_files_changed" | "branch_deleted" | "imported_git_changed" | "imported_pull_request_changed";
|
|
313
|
-
/** Existing branch scope. */
|
|
314
|
-
branch_id?: string | null;
|
|
315
|
-
}
|
|
316
|
-
/** Mapping of wire event names to decoded public payloads. */
|
|
302
|
+
/** `image.resolved`: a generated image finished or failed. Replace its `placeholder_url` wherever it appears. */
|
|
303
|
+
export type ImageResolved = ToolMediaResult;
|
|
304
|
+
/** Mapping of public event names to their payloads. */
|
|
317
305
|
export interface PlatformEventMap {
|
|
318
|
-
/**
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
|
|
306
|
+
/** A chat message was added or replaced. */
|
|
307
|
+
"message.updated": MessageUpdated;
|
|
308
|
+
/** A chat message was removed or hidden. */
|
|
309
|
+
"message.removed": MessageRemoved;
|
|
310
|
+
/** The builder started, finished or failed a turn. */
|
|
311
|
+
"app.status_changed": AppStatusChanged;
|
|
312
|
+
/** Reload the app preview. */
|
|
313
|
+
"preview.reload_requested": BranchScoped;
|
|
314
|
+
/** Show a page of the app in the preview. */
|
|
315
|
+
"preview.navigation_requested": PreviewNavigationRequested;
|
|
316
|
+
/** The whole prompt queue. */
|
|
317
|
+
"queue.updated": QueueUpdated;
|
|
318
|
+
/** Progress of a long-running tool. */
|
|
319
|
+
"task.progressed": TaskProgressed;
|
|
320
|
+
/** A generated image finished or failed. */
|
|
321
|
+
"image.resolved": ImageResolved;
|
|
322
|
+
/** The conversation was rewritten (undo, restore, sync). On main, the SDK rejoins for a fresh snapshot. */
|
|
323
|
+
"conversation.changed": BranchScoped;
|
|
324
|
+
/** The app's files changed outside a chat turn. Re-read them. */
|
|
325
|
+
"files.changed": BranchScoped;
|
|
326
|
+
/** A branch was deleted. */
|
|
327
|
+
"branch.deleted": BranchScoped;
|
|
328
|
+
/** The imported app's repository changed. */
|
|
329
|
+
"repository.changed": BranchScoped;
|
|
330
|
+
/** The imported app's pull request changed. */
|
|
331
|
+
"pull_request.changed": BranchScoped;
|
|
328
332
|
}
|
|
329
|
-
/** Ordered delivery
|
|
333
|
+
/** Ordered delivery of one public event. */
|
|
330
334
|
export type PlatformEvent = {
|
|
331
335
|
[K in keyof PlatformEventMap]: {
|
|
332
|
-
/**
|
|
336
|
+
/** Public event name; narrows the payload type. */
|
|
333
337
|
type: K;
|
|
334
338
|
/** Authorized app receiving this event. */
|
|
335
339
|
appId: string;
|
|
336
|
-
/**
|
|
340
|
+
/** Event payload. Omitted keys mean unchanged; explicit null clears. */
|
|
337
341
|
data: PlatformEventMap[K];
|
|
338
342
|
};
|
|
339
343
|
}[keyof PlatformEventMap];
|
|
340
|
-
/** An app's current state: sent after
|
|
344
|
+
/** An app's current state: sent after every join and rejoin, and after a main-conversation rewrite. */
|
|
341
345
|
export interface Snapshot {
|
|
342
346
|
/** Canonical app room. */
|
|
343
347
|
room: string;
|
|
@@ -28,7 +28,7 @@ export interface BuilderSession {
|
|
|
28
28
|
/** One app subscription; at most eight may be active per builder session. */
|
|
29
29
|
export interface SubscriptionOptions {
|
|
30
30
|
/** Replace this app's state. Arrives after every join and rejoin, and after a main-conversation
|
|
31
|
-
* rewrite (undo, restore, sync). Live events
|
|
31
|
+
* rewrite (undo, restore, sync). Live events follow it; it holds only the last 50 messages.
|
|
32
32
|
*/
|
|
33
33
|
onSnapshot: (snapshot: Snapshot) => void | Promise<void>;
|
|
34
34
|
/** Apply each live event. Delivery is serial per app; a rejection ends this subscription. */
|