@chatu-ai/builder-sdk 0.7.2 → 0.7.4

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 CHANGED
@@ -117,6 +117,13 @@ export type DeployStreamEvent = {
117
117
  type: 'result';
118
118
  result: DeployResult;
119
119
  };
120
+ export type GitPushStreamEvent = {
121
+ type: 'log';
122
+ line: string;
123
+ } | {
124
+ type: 'result';
125
+ result: GitPushResult;
126
+ };
120
127
  export interface DeployInput {
121
128
  provider: 'edgeone';
122
129
  projectName: string;
@@ -223,6 +230,10 @@ export interface BuilderClient {
223
230
  }): Promise<DeploySettingView>;
224
231
  /** 推送到用户 Git 仓库;沙箱未运行时 ok=false, error='SANDBOX_NOT_RUNNING' */
225
232
  pushGit(conversationId: string, input: GitPushInput): Promise<GitPushResult>;
233
+ /** 推送到 Git(SSE 进度版):逐行 log 事件 + 最终 result;沙箱未运行时 result.error=SANDBOX_NOT_RUNNING */
234
+ pushGitStream(conversationId: string, input: GitPushInput, opts?: {
235
+ signal?: AbortSignal;
236
+ }): AsyncIterable<GitPushStreamEvent>;
226
237
  /** 一键部署(P1:EdgeOne Pages);沙箱未运行时 ok=false, error='SANDBOX_NOT_RUNNING' */
227
238
  deploy(conversationId: string, input: DeployInput): Promise<DeployResult>;
228
239
  /** 一键部署(流式进度):逐条产出 log 行,最后一条为 result */
package/dist/client.js CHANGED
@@ -93,6 +93,7 @@ export function createBuilderClient(options) {
93
93
  settings: id => req(`/${id}/deploy-settings`),
94
94
  saveSetting: (id, input) => req(`/${id}/deploy-settings`, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
95
95
  pushGit: (id, input) => req(`/${id}/export/git`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
96
+ 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
97
  deploy: (id, input) => req(`/${id}/export/deploy`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(input) }),
97
98
  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
99
  },
@@ -192,7 +193,7 @@ async function* readNamedSse(url, init, doFetch) {
192
193
  if (eventName === 'log')
193
194
  yield { type: 'log', line: String(payload?.line ?? payload) };
194
195
  else if (eventName === 'result')
195
- yield { type: 'result', result: payload };
196
+ yield { type: 'result', result: normalizeKeys(payload) };
196
197
  eventName = '';
197
198
  }
198
199
  }
@@ -201,6 +202,17 @@ async function* readNamedSse(url, init, doFetch) {
201
202
  reader.releaseLock();
202
203
  }
203
204
  }
205
+ /** 服务端 SSE 序列化可能是 PascalCase(Ok/Url)——统一成 camelCase */
206
+ function normalizeKeys(obj) {
207
+ if (!obj || typeof obj !== 'object' || Array.isArray(obj))
208
+ return obj;
209
+ if ('ok' in obj || !('Ok' in obj))
210
+ return obj;
211
+ const out = {};
212
+ for (const [k, v] of Object.entries(obj))
213
+ out[k.charAt(0).toLowerCase() + k.slice(1)] = v;
214
+ return out;
215
+ }
204
216
  function encPath(key) {
205
217
  return key.split('/').map(encodeURIComponent).join('/');
206
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatu-ai/builder-sdk",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "ChatU Builder client SDK core: REST + streaming client, zod event schemas, seq resume",
5
5
  "license": "MIT",
6
6
  "type": "module",