@chatu-ai/builder-sdk 0.6.1 → 0.6.3

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
@@ -165,14 +165,21 @@ export interface BuilderClient {
165
165
  restore(conversationId: string, sha: string): Promise<void>;
166
166
  };
167
167
  files: {
168
+ /** 文件树:默认只返回 path 的直接子项(depth=0),按需逐层展开;depth 最多 3 */
168
169
  tree(conversationId: string, opts?: {
169
170
  path?: string;
170
171
  ref?: string;
172
+ depth?: number;
171
173
  }): Promise<FileNode[]>;
172
174
  read(conversationId: string, path: string, opts?: {
173
175
  ref?: string;
174
176
  }): Promise<string>;
175
177
  downloadUrl(conversationId: string): string;
178
+ /** 原样下载单个文件(图片/PDF 等预览用),返回 Blob 与 content-type */
179
+ download(conversationId: string, path: string): Promise<{
180
+ blob: Blob;
181
+ contentType: string;
182
+ }>;
176
183
  };
177
184
  /** 凭据库(技术方案 14 §2):列表脱敏,永不返回明文 */
178
185
  credentials: {
package/dist/client.js CHANGED
@@ -70,11 +70,17 @@ export function createBuilderClient(options) {
70
70
  files: {
71
71
  // 服务端形状:{ tree: FileNode[] }
72
72
  tree: async (id, opts) => {
73
- const r = await req(`/${id}/files?${qs(opts)}`);
73
+ const r = await req(`/${id}/files?${qs({ path: opts?.path, ref: opts?.ref, depth: opts?.depth })}`);
74
74
  return Array.isArray(r) ? r : (r.tree ?? []);
75
75
  },
76
76
  read: (id, path, opts) => req(`/${id}/files/read?${qs({ path, ...opts })}`),
77
77
  downloadUrl: id => `${restBase}/${id}/files/download`,
78
+ download: async (id, path) => {
79
+ const res = await doFetch(`${restBase}/${id}/files/download?path=${encodeURIComponent(path)}`, auth.apply({}));
80
+ if (!res.ok)
81
+ throw new BuilderApiError(res.status, await res.text().catch(() => ''));
82
+ return { blob: await res.blob(), contentType: res.headers.get('content-type') ?? 'application/octet-stream' };
83
+ },
78
84
  },
79
85
  credentials: {
80
86
  list: conversationId => req(`/credentials${conversationId ? `?conversationId=${encodeURIComponent(conversationId)}` : ''}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatu-ai/builder-sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "ChatU Builder client SDK core: REST + streaming client, zod event schemas, seq resume",
5
5
  "license": "MIT",
6
6
  "type": "module",