@chatu-ai/builder-sdk 0.7.3 → 0.7.5
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 +25 -0
- package/dist/client.js +14 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ export interface SandboxStatus {
|
|
|
39
39
|
startingForMs?: number | null;
|
|
40
40
|
lastError?: string | null;
|
|
41
41
|
} | null;
|
|
42
|
+
/** runtime 内是否仍有生成在跑(上一轮连接中断后后台继续):xid 可用于取消 */
|
|
43
|
+
agent?: {
|
|
44
|
+
executing: boolean;
|
|
45
|
+
xid?: string | null;
|
|
46
|
+
sinceMs?: number | null;
|
|
47
|
+
} | null;
|
|
42
48
|
}
|
|
43
49
|
export interface VersionInfo {
|
|
44
50
|
sha: string;
|
|
@@ -117,6 +123,13 @@ export type DeployStreamEvent = {
|
|
|
117
123
|
type: 'result';
|
|
118
124
|
result: DeployResult;
|
|
119
125
|
};
|
|
126
|
+
export type GitPushStreamEvent = {
|
|
127
|
+
type: 'log';
|
|
128
|
+
line: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: 'result';
|
|
131
|
+
result: GitPushResult;
|
|
132
|
+
};
|
|
120
133
|
export interface DeployInput {
|
|
121
134
|
provider: 'edgeone';
|
|
122
135
|
projectName: string;
|
|
@@ -176,6 +189,14 @@ export interface BuilderClient {
|
|
|
176
189
|
revokeShare(conversationId: string, token: string): Promise<{
|
|
177
190
|
ok: boolean;
|
|
178
191
|
}>;
|
|
192
|
+
/** 重启 dev server(clean=true 先清 .next/.turbo 构建缓存);服务端立即返回,就绪状态用 status().devServer.ready 轮询 */
|
|
193
|
+
restartDevServer(conversationId: string, opts?: {
|
|
194
|
+
clean?: boolean;
|
|
195
|
+
}): Promise<{
|
|
196
|
+
ok: boolean;
|
|
197
|
+
ready?: boolean;
|
|
198
|
+
cleaned?: boolean;
|
|
199
|
+
}>;
|
|
179
200
|
};
|
|
180
201
|
versions: {
|
|
181
202
|
list(conversationId: string, opts?: {
|
|
@@ -223,6 +244,10 @@ export interface BuilderClient {
|
|
|
223
244
|
}): Promise<DeploySettingView>;
|
|
224
245
|
/** 推送到用户 Git 仓库;沙箱未运行时 ok=false, error='SANDBOX_NOT_RUNNING' */
|
|
225
246
|
pushGit(conversationId: string, input: GitPushInput): Promise<GitPushResult>;
|
|
247
|
+
/** 推送到 Git(SSE 进度版):逐行 log 事件 + 最终 result;沙箱未运行时 result.error=SANDBOX_NOT_RUNNING */
|
|
248
|
+
pushGitStream(conversationId: string, input: GitPushInput, opts?: {
|
|
249
|
+
signal?: AbortSignal;
|
|
250
|
+
}): AsyncIterable<GitPushStreamEvent>;
|
|
226
251
|
/** 一键部署(P1:EdgeOne Pages);沙箱未运行时 ok=false, error='SANDBOX_NOT_RUNNING' */
|
|
227
252
|
deploy(conversationId: string, input: DeployInput): Promise<DeployResult>;
|
|
228
253
|
/** 一键部署(流式进度):逐条产出 log 行,最后一条为 result */
|
package/dist/client.js
CHANGED
|
@@ -60,6 +60,7 @@ export function createBuilderClient(options) {
|
|
|
60
60
|
wake: id => req(`/sandbox/${id}/wake`, { method: 'POST' }),
|
|
61
61
|
share: (id, ttlHours) => req(`/${id}/preview-share`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ttlHours }) }),
|
|
62
62
|
revokeShare: (id, token) => req(`/${id}/preview-share/revoke`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ token }) }),
|
|
63
|
+
restartDevServer: (id, opts) => req(`/${id}/devserver/restart?clean=${opts?.clean ? 'true' : 'false'}`, { method: 'POST' }),
|
|
63
64
|
},
|
|
64
65
|
versions: {
|
|
65
66
|
// 服务端形状:{ versions: VersionInfo[] }(runtime 透传)
|
|
@@ -93,6 +94,7 @@ export function createBuilderClient(options) {
|
|
|
93
94
|
settings: id => req(`/${id}/deploy-settings`),
|
|
94
95
|
saveSetting: (id, input) => req(`/${id}/deploy-settings`, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
|
|
95
96
|
pushGit: (id, input) => req(`/${id}/export/git`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
|
|
97
|
+
pushGitStream: (id, input, o) => readNamedSse(`${restBase}/${id}/export/git/stream`, auth.apply({ method: 'POST', headers: { 'content-type': 'application/json', accept: 'text/event-stream' }, body: JSON.stringify(input), signal: o?.signal }), doFetch),
|
|
96
98
|
deploy: (id, input) => req(`/${id}/export/deploy`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
|
|
97
99
|
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),
|
|
98
100
|
},
|
|
@@ -192,7 +194,7 @@ async function* readNamedSse(url, init, doFetch) {
|
|
|
192
194
|
if (eventName === 'log')
|
|
193
195
|
yield { type: 'log', line: String(payload?.line ?? payload) };
|
|
194
196
|
else if (eventName === 'result')
|
|
195
|
-
yield { type: 'result', result: payload };
|
|
197
|
+
yield { type: 'result', result: normalizeKeys(payload) };
|
|
196
198
|
eventName = '';
|
|
197
199
|
}
|
|
198
200
|
}
|
|
@@ -201,6 +203,17 @@ async function* readNamedSse(url, init, doFetch) {
|
|
|
201
203
|
reader.releaseLock();
|
|
202
204
|
}
|
|
203
205
|
}
|
|
206
|
+
/** 服务端 SSE 序列化可能是 PascalCase(Ok/Url)——统一成 camelCase */
|
|
207
|
+
function normalizeKeys(obj) {
|
|
208
|
+
if (!obj || typeof obj !== 'object' || Array.isArray(obj))
|
|
209
|
+
return obj;
|
|
210
|
+
if ('ok' in obj || !('Ok' in obj))
|
|
211
|
+
return obj;
|
|
212
|
+
const out = {};
|
|
213
|
+
for (const [k, v] of Object.entries(obj))
|
|
214
|
+
out[k.charAt(0).toLowerCase() + k.slice(1)] = v;
|
|
215
|
+
return out;
|
|
216
|
+
}
|
|
204
217
|
function encPath(key) {
|
|
205
218
|
return key.split('/').map(encodeURIComponent).join('/');
|
|
206
219
|
}
|