@chatu-ai/builder-sdk 0.9.5 → 0.9.7
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/client.d.ts +26 -0
- package/dist/client.js +3 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -315,6 +315,23 @@ export interface BuilderClient {
|
|
|
315
315
|
state?: SandboxState | string;
|
|
316
316
|
}>;
|
|
317
317
|
/** 一次性预览 token(06 §6.1):返回可直接作 iframe src 的带 ?t= 的 URL */
|
|
318
|
+
/** 快照清单(新→旧):沙箱信息面板展示"有几个快照、多大、什么时候" */
|
|
319
|
+
snapshots(conversationId: string): Promise<{
|
|
320
|
+
ok: boolean;
|
|
321
|
+
error?: string;
|
|
322
|
+
snapshots: Array<{
|
|
323
|
+
key: string;
|
|
324
|
+
bytes: number;
|
|
325
|
+
createdAt: number;
|
|
326
|
+
}>;
|
|
327
|
+
}>;
|
|
328
|
+
/** 恢复到指定快照(覆盖工作区文件并重启 dev server);AI 生成中返回 ok:false, error:'BUSY' */
|
|
329
|
+
restoreSnapshot(conversationId: string, key: string): Promise<{
|
|
330
|
+
ok: boolean;
|
|
331
|
+
error?: string;
|
|
332
|
+
message?: string;
|
|
333
|
+
key?: string;
|
|
334
|
+
}>;
|
|
318
335
|
/** port:应用自己起的第二个服务(多端口预览);不传即 dev server */
|
|
319
336
|
previewToken(conversationId: string, opts?: {
|
|
320
337
|
port?: number | null;
|
|
@@ -418,6 +435,15 @@ export interface BuilderClient {
|
|
|
418
435
|
signal?: AbortSignal;
|
|
419
436
|
}): AsyncIterable<FunctionDeployStreamEvent>;
|
|
420
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* 生成事件里的单条消息全文(技术方案 22 S2):平台把超大的工具结果改为"预览 + 引用"下发,
|
|
440
|
+
* 前端展开时用 `chatuRef`(`{xid}/{seq}`)回取完整内容。
|
|
441
|
+
*/
|
|
442
|
+
runMessage(conversationId: string, xid: string, seq: number): Promise<{
|
|
443
|
+
ok: boolean;
|
|
444
|
+
error?: string;
|
|
445
|
+
message?: Record<string, unknown>;
|
|
446
|
+
}>;
|
|
421
447
|
/** 沙箱终端(001/09 P2-A):执行一条命令并流式回输出;AI 生成中会被拒绝(409) */
|
|
422
448
|
exec(conversationId: string, command: string, opts?: {
|
|
423
449
|
timeoutMs?: number;
|
package/dist/client.js
CHANGED
|
@@ -57,6 +57,8 @@ export function createBuilderClient(options) {
|
|
|
57
57
|
body: JSON.stringify(opts),
|
|
58
58
|
}),
|
|
59
59
|
previewToken: (id, opts) => req(`/${id}/preview-token?${qs({ port: opts?.port ?? undefined })}`),
|
|
60
|
+
snapshots: id => req(`/sandbox/${id}/snapshots`),
|
|
61
|
+
restoreSnapshot: (id, key) => req(`/sandbox/${id}/snapshots/restore`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ key }) }),
|
|
60
62
|
wake: id => req(`/sandbox/${id}/wake`, { method: 'POST' }),
|
|
61
63
|
share: (id, ttlHours) => req(`/${id}/preview-share`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ttlHours }) }),
|
|
62
64
|
revokeShare: (id, token) => req(`/${id}/preview-share/revoke`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ token }) }),
|
|
@@ -103,6 +105,7 @@ export function createBuilderClient(options) {
|
|
|
103
105
|
deployFunctionStream: (id, input, o) => readNamedSse(`${restBase}/${id}/export/deploy-function/stream`, auth.apply({ method: 'POST', headers: { 'content-type': 'application/json', accept: 'text/event-stream' }, body: JSON.stringify(input), signal: o?.signal }), doFetch),
|
|
104
106
|
deployStream: (id, input, o) => readNamedSse(`${restBase}/${id}/export/deploy/stream`, auth.apply({ method: 'POST', headers: { 'content-type': 'application/json', accept: 'text/event-stream' }, body: JSON.stringify(input), signal: o?.signal }), doFetch),
|
|
105
107
|
},
|
|
108
|
+
runMessage: (id, xid, seq) => req(`/${id}/runs/${encPath(xid)}/messages/${seq}`),
|
|
106
109
|
exec: (id, command, o) => readNamedSse(`${restBase}/${id}/exec/stream`, auth.apply({ method: 'POST', headers: { 'content-type': 'application/json', accept: 'text/event-stream' }, body: JSON.stringify({ command, timeoutMs: o?.timeoutMs }), signal: o?.signal }), doFetch),
|
|
107
110
|
data: {
|
|
108
111
|
access: id => req(`/${id}/data-access`),
|