@chatu-ai/builder-sdk 0.9.2 → 0.9.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
@@ -38,6 +38,8 @@ export interface SandboxStatus {
38
38
  ready?: boolean;
39
39
  startingForMs?: number | null;
40
40
  lastError?: string | null;
41
+ /** 沙箱内处于 LISTEN 的端口,首个为 dev server;用于多端口预览切换 */
42
+ ports?: number[] | null;
41
43
  /** 最近一次异常退出;gaveUp=true 表示 runtime 已停止自动重启,需要修代码后手动重启 */
42
44
  crash?: {
43
45
  at?: string | null;
@@ -250,6 +252,23 @@ export type GitPushStreamEvent = {
250
252
  type: 'result';
251
253
  result: GitPushResult;
252
254
  };
255
+ /** 沙箱终端:一次一条命令的执行结果 */
256
+ export interface ExecResult {
257
+ ok: boolean;
258
+ code?: number | null;
259
+ signal?: string | null;
260
+ truncated?: boolean;
261
+ durationMs?: number;
262
+ error?: string | null;
263
+ message?: string | null;
264
+ }
265
+ export type ExecStreamEvent = {
266
+ type: 'log';
267
+ line: string;
268
+ } | {
269
+ type: 'result';
270
+ result: ExecResult;
271
+ };
253
272
  export interface DeployInput {
254
273
  provider: 'edgeone';
255
274
  projectName: string;
@@ -296,7 +315,10 @@ export interface BuilderClient {
296
315
  state?: SandboxState | string;
297
316
  }>;
298
317
  /** 一次性预览 token(06 §6.1):返回可直接作 iframe src 的带 ?t= 的 URL */
299
- previewToken(conversationId: string): Promise<{
318
+ /** port:应用自己起的第二个服务(多端口预览);不传即 dev server */
319
+ previewToken(conversationId: string, opts?: {
320
+ port?: number | null;
321
+ }): Promise<{
300
322
  token: string;
301
323
  previewUrl: string;
302
324
  }>;
@@ -396,6 +418,11 @@ export interface BuilderClient {
396
418
  signal?: AbortSignal;
397
419
  }): AsyncIterable<FunctionDeployStreamEvent>;
398
420
  };
421
+ /** 沙箱终端(001/09 P2-A):执行一条命令并流式回输出;AI 生成中会被拒绝(409) */
422
+ exec(conversationId: string, command: string, opts?: {
423
+ timeoutMs?: number;
424
+ signal?: AbortSignal;
425
+ }): AsyncIterable<ExecStreamEvent>;
399
426
  /** 平台数据能力接入信息(技术方案 15):线上部署所需环境变量;apiKey 为服务端密钥 */
400
427
  data: {
401
428
  access(conversationId: string): Promise<{
package/dist/client.js CHANGED
@@ -56,7 +56,7 @@ export function createBuilderClient(options) {
56
56
  headers: { 'content-type': 'application/json' },
57
57
  body: JSON.stringify(opts),
58
58
  }),
59
- previewToken: id => req(`/${id}/preview-token`),
59
+ previewToken: (id, opts) => req(`/${id}/preview-token?${qs({ port: opts?.port ?? undefined })}`),
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 }) }),
@@ -103,6 +103,7 @@ export function createBuilderClient(options) {
103
103
  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
104
  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
105
  },
106
+ 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),
106
107
  data: {
107
108
  access: id => req(`/${id}/data-access`),
108
109
  usage: id => req(`/${id}/data-usage`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatu-ai/builder-sdk",
3
- "version": "0.9.2",
3
+ "version": "0.9.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",