@tencent-ai/workbuddy-cloud-sdk 0.1.0-dev.dee063d.202608201621 → 0.1.1-dev.520de95.202609090209
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/README.md +28 -0
- package/lib/index.cjs +216 -86
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +280 -44
- package/lib/index.d.ts +280 -44
- package/lib/index.global.js +4 -4
- package/lib/index.global.js.map +1 -1
- package/lib/index.js +214 -86
- package/lib/index.js.map +1 -1
- package/lib/miniprogram.cjs +9764 -0
- package/lib/miniprogram.cjs.map +1 -0
- package/lib/miniprogram.d.cts +6794 -0
- package/lib/miniprogram.d.ts +6794 -0
- package/lib/miniprogram.js +9734 -0
- package/lib/miniprogram.js.map +1 -0
- package/miniprogram_dist/miniprogram.js +14749 -0
- package/package.json +33 -4
package/lib/index.d.cts
CHANGED
|
@@ -149,11 +149,22 @@ interface PasswordCredentials {
|
|
|
149
149
|
email: string;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
152
|
+
* 验证码注册凭据。
|
|
153
|
+
*
|
|
154
|
+
* `email` / `phone` 二选一(与发码渠道一致);`password` 可选 —— 短信注册通常
|
|
155
|
+
* 不设密码。
|
|
156
|
+
*/
|
|
157
|
+
interface SignUpCredentials {
|
|
158
|
+
email?: string;
|
|
159
|
+
phone?: string;
|
|
160
|
+
password?: string;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 验证码登录 —— 发码阶段。邮箱与手机号**二选一**,由传入字段决定投递渠道。
|
|
153
164
|
*
|
|
154
165
|
* 发码由 provider 完成,我方不实现发码逻辑(§7.5.1)。
|
|
155
166
|
*/
|
|
156
|
-
|
|
167
|
+
type OtpCredentials = {
|
|
157
168
|
email: string;
|
|
158
169
|
/**
|
|
159
170
|
* 邮件里「点此登录」链接的落地地址。
|
|
@@ -162,7 +173,19 @@ interface OtpCredentials {
|
|
|
162
173
|
* A 应用可以让 provider 发一封跳转到攻击者站点的我方品牌邮件。
|
|
163
174
|
*/
|
|
164
175
|
emailRedirectTo?: string;
|
|
165
|
-
|
|
176
|
+
phone?: never;
|
|
177
|
+
} | {
|
|
178
|
+
/**
|
|
179
|
+
* 手机号,SDK 会归一化为 `+86 13800000000` 这类带区号形式。
|
|
180
|
+
*
|
|
181
|
+
* 兼容裸号(`13800000000`)、无空格区号(`+8613800000000`)、国际冠码
|
|
182
|
+
* (`0086...`)及各种分隔符;非国内手机号(如港澳号 `+852...`)原样透传,
|
|
183
|
+
* 不会被改坏。
|
|
184
|
+
*/
|
|
185
|
+
phone: string;
|
|
186
|
+
email?: never;
|
|
187
|
+
emailRedirectTo?: never;
|
|
188
|
+
};
|
|
166
189
|
/**
|
|
167
190
|
* 发码结果。
|
|
168
191
|
*
|
|
@@ -171,6 +194,8 @@ interface OtpCredentials {
|
|
|
171
194
|
*/
|
|
172
195
|
interface OtpVerifyCredentials {
|
|
173
196
|
token: string;
|
|
197
|
+
/** 注册路径可选设置密码;已存在用户忽略此项。 */
|
|
198
|
+
password?: string;
|
|
174
199
|
}
|
|
175
200
|
interface OtpChallenge {
|
|
176
201
|
verificationId: string;
|
|
@@ -183,13 +208,19 @@ interface OtpSignInChallenge extends OtpChallenge {
|
|
|
183
208
|
/** 输入验证码并完成登录/注册。 */
|
|
184
209
|
verify(credentials: OtpVerifyCredentials): Promise<CloudResult<CloudSession>>;
|
|
185
210
|
}
|
|
186
|
-
/**
|
|
211
|
+
/**
|
|
212
|
+
* 验码阶段的入参。
|
|
213
|
+
*
|
|
214
|
+
* `email` / `phone` 二选一,且必须与发码时用的那个一致 —— 上游按同一标识换会话。
|
|
215
|
+
*/
|
|
187
216
|
interface VerifyOtpParams {
|
|
188
217
|
verificationId: string;
|
|
189
218
|
/** 用户输入的验证码。 */
|
|
190
219
|
token: string;
|
|
191
|
-
/**
|
|
192
|
-
email
|
|
220
|
+
/** 与发码时一致的邮箱。手机号发码时传 {@link phone} 代替。 */
|
|
221
|
+
email?: string;
|
|
222
|
+
/** 与发码时一致的手机号。邮箱发码时传 {@link email} 代替。 */
|
|
223
|
+
phone?: string;
|
|
193
224
|
/** 注册路径可选设置密码;已存在用户忽略此项。 */
|
|
194
225
|
password?: string;
|
|
195
226
|
}
|
|
@@ -250,16 +281,29 @@ type CloudModuleName = 'auth' | 'database' | 'storage' | 'llm';
|
|
|
250
281
|
* 任何响应都不下发(设计文档 §5.2),因此不要为它们加配置项。
|
|
251
282
|
*/
|
|
252
283
|
interface WorkBuddyCloudOptions {
|
|
253
|
-
/**
|
|
254
|
-
|
|
284
|
+
/**
|
|
285
|
+
* 数据面基址,例如 `https://app.workbuddy.link`。末尾斜杠会被归一化掉。
|
|
286
|
+
*
|
|
287
|
+
* **省略即用当前页面同源,这是推荐用法** —— 数据面 `/.cloud/**` 与应用页面本就
|
|
288
|
+
* 同域,同源永远正确。显式传绝对地址反而有失效模式:它会被写进前端产物,应用
|
|
289
|
+
* 重新发布 / 追加认证域名后拿到新域名,产物里的旧地址不变,请求便打到旧域名上,
|
|
290
|
+
* 而服务端按 Origin 精确匹配必然拒绝(现场表现为跨域预检失败,极难归因)。
|
|
291
|
+
*
|
|
292
|
+
* 需要显式传的场景:本地开发页面跑在 dev server、数据面在别处;以及非浏览器
|
|
293
|
+
* 运行时(无 `location.origin` 可回落,此时省略会抛配置错误)。
|
|
294
|
+
*/
|
|
295
|
+
endpoint?: string;
|
|
255
296
|
/**
|
|
256
297
|
* Google OAuth Relay 的环境中心基址,例如
|
|
257
298
|
* `https://test4-api.workbuddy.cn/v2/as/genie-baas/oauth`。
|
|
258
299
|
*
|
|
259
300
|
* 它与 endpoint 是两条入口:endpoint 是每应用发布域名,承载 `/.cloud/**`;
|
|
260
301
|
* OAuth Relay 走中心 APISIX,不能根据 endpoint 拼接。
|
|
302
|
+
*
|
|
303
|
+
* @deprecated Google 登录已下线,新应用不再下发该字段;此处保留仅为兼容
|
|
304
|
+
* 已发布应用的存量配置。省略时 `oauthRelayBaseUrl` 回落为空串。
|
|
261
305
|
*/
|
|
262
|
-
oauthRelayBaseUrl
|
|
306
|
+
oauthRelayBaseUrl?: string;
|
|
263
307
|
/**
|
|
264
308
|
* 我方签发的半公开 key,格式 `wbpk_{appId}_{随机}`。
|
|
265
309
|
*
|
|
@@ -354,23 +398,37 @@ declare class AuthModule {
|
|
|
354
398
|
getAccessToken(): Promise<string | undefined>;
|
|
355
399
|
/** 邮箱 + 密码登录。当前环境未启用手机号或匿名登录。 */
|
|
356
400
|
signInWithPassword(credentials: PasswordCredentials): Promise<CloudResult<CloudSession>>;
|
|
401
|
+
/**
|
|
402
|
+
* 小程序 wx.login 的 code 换 Genie session。
|
|
403
|
+
* 试用与正式是两套独立小程序,必须带当前账号的 appid
|
|
404
|
+
*(`wx.getAccountInfoSync().miniProgram.appId`)。
|
|
405
|
+
*/
|
|
406
|
+
signInWithWechat(code: string, appid: string): Promise<CloudResult<CloudSession>>;
|
|
357
407
|
/**
|
|
358
408
|
* 注册。
|
|
359
409
|
*
|
|
360
410
|
* 上游要求先完成验证码验证,所以必须带一个 `verificationToken`(来自
|
|
361
411
|
* `verifyOtp`)。只有用户名+密码的注册会被上游明确拒绝。
|
|
412
|
+
*
|
|
413
|
+
* 账号标识用 `email` 或 `phone`(二选一,与发码渠道一致)。
|
|
362
414
|
*/
|
|
363
|
-
signUp(credentials:
|
|
415
|
+
signUp(credentials: SignUpCredentials & {
|
|
364
416
|
verificationToken: string;
|
|
365
417
|
}): Promise<CloudResult<CloudSession>>;
|
|
366
418
|
/**
|
|
367
|
-
*
|
|
419
|
+
* 发验证码(邮箱或短信,由 `credentials` 传的字段决定)。
|
|
368
420
|
*
|
|
369
421
|
* 这一步**不产生会话**,只返回一个 `verificationId`。发码由上游完成,
|
|
370
422
|
* 我方不实现发码逻辑。
|
|
371
423
|
*
|
|
372
424
|
* 返回的 `isExistingUser` 决定验码之后走登录还是注册 —— 该判断由上游给出,
|
|
373
425
|
* SDK 不猜。
|
|
426
|
+
*
|
|
427
|
+
* 两条渠道的请求体差异是刻意的(runtime-auth-design §3.1):
|
|
428
|
+
* - 邮箱:`{ email, usage: 'EMAIL' }`
|
|
429
|
+
* - 手机:`{ phone_number, target: 'ANY' }` —— **不带 `usage`**(普通短信登录
|
|
430
|
+
* 发码时省略即可,上游没有对应的短信枚举值),`target: 'ANY'` 表示新老用户
|
|
431
|
+
* 都允许发码。
|
|
374
432
|
*/
|
|
375
433
|
sendOtp(credentials: OtpCredentials): Promise<CloudResult<OtpChallenge>>;
|
|
376
434
|
/** gotrue 风格的 OTP 入口:发码后由 challenge.verify 完成登录。 */
|
|
@@ -384,6 +442,9 @@ declare class AuthModule {
|
|
|
384
442
|
* 走登录还是注册由 `isExistingUser` 决定(`sendOtp` 的返回值)。刻意不做
|
|
385
443
|
* 「先试登录失败再试注册」的兜底:那会把「密码错」这类真实错误掩盖成一次
|
|
386
444
|
* 莫名的注册尝试。
|
|
445
|
+
*
|
|
446
|
+
* 登录侧邮箱与手机号共用 `username` 字段 —— 上游 `SignInRequest.username`
|
|
447
|
+
* 承载邮箱/手机/用户名三种形态(runtime-auth-design §3.2)。
|
|
387
448
|
*/
|
|
388
449
|
verifyOtp(params: VerifyOtpParams & {
|
|
389
450
|
isExistingUser: boolean;
|
|
@@ -397,6 +458,8 @@ declare class AuthModule {
|
|
|
397
458
|
*
|
|
398
459
|
* SDK 不自己跳转(不写 `location.href`):跳转时机应由应用决定 —— 有的要
|
|
399
460
|
* 先存草稿,有的在 iframe 里要开弹窗。返回 url 交调用方处置。
|
|
461
|
+
*
|
|
462
|
+
* @deprecated Google 登录已下线,新应用不应再调用该方法。
|
|
400
463
|
*/
|
|
401
464
|
signInWithOAuth(options: OAuthSignInOptions): Promise<CloudResult<OAuthRedirect>>;
|
|
402
465
|
/**
|
|
@@ -404,6 +467,8 @@ declare class AuthModule {
|
|
|
404
467
|
*
|
|
405
468
|
* 在回调落地页调一次即可。`code` 缺失时返回 `null` 数据而**不是**错误 ——
|
|
406
469
|
* 落地页可能被直接访问(用户收藏了它),那不是失败。
|
|
470
|
+
*
|
|
471
|
+
* @deprecated Google 登录已下线,新应用不应再调用该方法。
|
|
407
472
|
*/
|
|
408
473
|
handleOAuthCallback(search?: string): Promise<CloudResult<CloudSession | null>>;
|
|
409
474
|
/** 忘记密码:发码,验证码通过后更新密码并自动登录。 */
|
|
@@ -441,7 +506,11 @@ declare class AuthModule {
|
|
|
441
506
|
* 「还没初始化完」与「初始化完了但未登录」,首屏会闪一下登录页。
|
|
442
507
|
*/
|
|
443
508
|
onAuthStateChange(callback: CloudAuthStateCallback): () => void;
|
|
444
|
-
/**
|
|
509
|
+
/**
|
|
510
|
+
* 拼出平台 Relay 授权地址;state 由 Relay 自己签发、校验并一次性消费。
|
|
511
|
+
*
|
|
512
|
+
* @deprecated Google 登录已下线,仅保留给存量应用的回调落地页。
|
|
513
|
+
*/
|
|
445
514
|
private startRelayOAuth;
|
|
446
515
|
/** 用我方句柄换新会话。这是 SessionManager 注入的续期执行体。 */
|
|
447
516
|
private exchangeRefreshHandle;
|
|
@@ -5859,9 +5928,9 @@ declare class WorkBuddyDatabaseModule<Database = unknown> {
|
|
|
5859
5928
|
*
|
|
5860
5929
|
* This is a browser-safe projection. It contains only display metadata,
|
|
5861
5930
|
* explicit capabilities, limits and public pricing supplied by GenieBaas.
|
|
5862
|
-
*
|
|
5863
|
-
*
|
|
5864
|
-
*
|
|
5931
|
+
* Sensitive connection and credential configuration is not included in the
|
|
5932
|
+
* directory. Optional capability or limit fields being absent means "unknown",
|
|
5933
|
+
* not "unsupported" or zero.
|
|
5865
5934
|
*/
|
|
5866
5935
|
interface PublicLLMModel {
|
|
5867
5936
|
/** Use this exact value as `model` in `chat.completions.create()`. */
|
|
@@ -5881,11 +5950,66 @@ interface PublicLLMModel {
|
|
|
5881
5950
|
maxOutputTokens?: number;
|
|
5882
5951
|
modalities?: PublicModelModalities;
|
|
5883
5952
|
capabilities?: PublicModelCapabilities;
|
|
5884
|
-
/**
|
|
5953
|
+
/**
|
|
5954
|
+
* Whether the directory currently marks this model as selectable.
|
|
5955
|
+
*
|
|
5956
|
+
* This is a directory selection hint; the actual call result is
|
|
5957
|
+
* determined by the request response, not by this field.
|
|
5958
|
+
*/
|
|
5885
5959
|
enabled: boolean;
|
|
5960
|
+
/**
|
|
5961
|
+
* Explicit disabled flag aligned with the console `disabled` field.
|
|
5962
|
+
* Present only when the server explicitly provides it:
|
|
5963
|
+
* - `disabled: true` → model is disabled, `enabled` will be `false`
|
|
5964
|
+
* - `disabled: false` → model is explicitly enabled, `enabled` will be `true`
|
|
5965
|
+
* - absent → server did not provide; `enabled` defaults to `true`
|
|
5966
|
+
*/
|
|
5967
|
+
disabled?: boolean;
|
|
5886
5968
|
isDefault?: boolean;
|
|
5887
5969
|
sortOrder?: number;
|
|
5888
5970
|
pricing?: PublicModelPricing;
|
|
5971
|
+
/** Credit display text, e.g. "2 credits/1K tokens". */
|
|
5972
|
+
credits?: string;
|
|
5973
|
+
/** Token threshold for starting context processing. */
|
|
5974
|
+
maxAllowedSize?: number;
|
|
5975
|
+
/** Whether multimodal capability is disabled. */
|
|
5976
|
+
disabledMultimodal?: boolean;
|
|
5977
|
+
/** Whether the model supports image input. */
|
|
5978
|
+
supportsImages?: boolean;
|
|
5979
|
+
/** Whether the model supports tool calls. */
|
|
5980
|
+
supportsToolCall?: boolean;
|
|
5981
|
+
/** Whether the model supports reasoning. */
|
|
5982
|
+
supportsReasoning?: boolean;
|
|
5983
|
+
/** Whether the model is reasoning-only. */
|
|
5984
|
+
onlyReasoning?: boolean;
|
|
5985
|
+
/** Reasoning configuration; sparse sub-fields are all optional. */
|
|
5986
|
+
reasoning?: PublicModelReasoning;
|
|
5987
|
+
/** Sampling temperature. */
|
|
5988
|
+
temperature?: number;
|
|
5989
|
+
/** Top-K sampling parameter. Field name kept as-is from productConfig (snake_case). */
|
|
5990
|
+
top_k?: number;
|
|
5991
|
+
/** Top-P (nucleus) sampling parameter. Field name kept as-is from productConfig (snake_case). */
|
|
5992
|
+
top_p?: number;
|
|
5993
|
+
/** Repetition penalty parameter. Field name kept as-is from productConfig (snake_case). */
|
|
5994
|
+
repetition_penalty?: number;
|
|
5995
|
+
}
|
|
5996
|
+
/**
|
|
5997
|
+
* Public reasoning configuration for a model.
|
|
5998
|
+
*
|
|
5999
|
+
* Sparse sub-fields: present only when the server explicitly provides them.
|
|
6000
|
+
* Explicit `false` is preserved and distinct from absence.
|
|
6001
|
+
*/
|
|
6002
|
+
interface PublicModelReasoning {
|
|
6003
|
+
/** Reasoning effort level (legacy, prefer defaultEffort). */
|
|
6004
|
+
effort?: string;
|
|
6005
|
+
/** Default effort level shown in UI. */
|
|
6006
|
+
defaultEffort?: string;
|
|
6007
|
+
/** Supported effort levels for UI display. */
|
|
6008
|
+
supportedEfforts?: string[];
|
|
6009
|
+
/** Reasoning summary mode. */
|
|
6010
|
+
summary?: 'auto' | 'concise' | 'detailed';
|
|
6011
|
+
/** Whether the user can disable thinking. */
|
|
6012
|
+
canDisableThinking?: boolean;
|
|
5889
6013
|
}
|
|
5890
6014
|
interface PublicModelModalities {
|
|
5891
6015
|
input?: string[];
|
|
@@ -5964,11 +6088,25 @@ interface ChatCompletionResponseFormat {
|
|
|
5964
6088
|
}
|
|
5965
6089
|
interface ChatCompletionCreateParams {
|
|
5966
6090
|
model: string;
|
|
6091
|
+
/**
|
|
6092
|
+
* ModelHub requires the first message to be an application-owned system prompt.
|
|
6093
|
+
* Include subsequent user/assistant turns after it; the SDK preserves this order.
|
|
6094
|
+
*/
|
|
5967
6095
|
messages: ChatCompletionRequestMessage[];
|
|
5968
|
-
|
|
6096
|
+
/**
|
|
6097
|
+
* Must be `true`. The API only supports streaming chat completions; the
|
|
6098
|
+
* SDK rejects any value that is not `true` before sending a request.
|
|
6099
|
+
*/
|
|
6100
|
+
stream: true;
|
|
5969
6101
|
stream_options?: ChatCompletionStreamOptions;
|
|
5970
6102
|
temperature?: number;
|
|
5971
6103
|
top_p?: number;
|
|
6104
|
+
/**
|
|
6105
|
+
* Not part of the OpenAI contract; forwarded to ModelHub's `ChatReq.repetition_penalty`.
|
|
6106
|
+
* Only takes effect on models that support it — see the `repetition_penalty` hint on the
|
|
6107
|
+
* corresponding `PublicLLMModel` from `models.list()`.
|
|
6108
|
+
*/
|
|
6109
|
+
repetition_penalty?: number;
|
|
5972
6110
|
max_tokens?: number;
|
|
5973
6111
|
max_completion_tokens?: number;
|
|
5974
6112
|
stop?: string | string[];
|
|
@@ -5982,13 +6120,17 @@ interface ChatCompletionCreateParams {
|
|
|
5982
6120
|
reasoning_effort?: 'minimal' | 'low' | 'medium' | 'high';
|
|
5983
6121
|
/** Caller-provided AbortSignal to cancel the request. */
|
|
5984
6122
|
signal?: AbortSignal;
|
|
6123
|
+
/** Application-managed conversation identifier sent as the X-Conversation-ID header. */
|
|
6124
|
+
conversationId?: string;
|
|
5985
6125
|
}
|
|
6126
|
+
/**
|
|
6127
|
+
* Alias for the streaming chat completion parameters.
|
|
6128
|
+
*
|
|
6129
|
+
* `stream: true` is required by the API contract; non-streaming is unsupported.
|
|
6130
|
+
*/
|
|
5986
6131
|
interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParams {
|
|
5987
6132
|
stream: true;
|
|
5988
6133
|
}
|
|
5989
|
-
interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParams {
|
|
5990
|
-
stream?: false;
|
|
5991
|
-
}
|
|
5992
6134
|
interface ChatCompletionMessageResponse {
|
|
5993
6135
|
role: 'assistant';
|
|
5994
6136
|
content: string | null;
|
|
@@ -6004,6 +6146,40 @@ interface CompletionUsage {
|
|
|
6004
6146
|
prompt_tokens: number;
|
|
6005
6147
|
completion_tokens: number;
|
|
6006
6148
|
total_tokens: number;
|
|
6149
|
+
/**
|
|
6150
|
+
* Optional reasoning-token breakdown reported by the model provider.
|
|
6151
|
+
*
|
|
6152
|
+
* Presence and semantics depend entirely on the upstream provider and
|
|
6153
|
+
* model; the SDK surfaces it when present but does not interpret or
|
|
6154
|
+
* validate it. It is diagnostic metadata, not a billing fact.
|
|
6155
|
+
*/
|
|
6156
|
+
reasoning_tokens?: number;
|
|
6157
|
+
/**
|
|
6158
|
+
* Optional prompt-prefix cache hit/miss metadata reported by the provider.
|
|
6159
|
+
*
|
|
6160
|
+
* Field names and shapes vary across providers; the SDK only forwards
|
|
6161
|
+
* the values it receives. Absence does not mean caching is unsupported.
|
|
6162
|
+
*/
|
|
6163
|
+
prompt_tokens_details?: Record<string, unknown>;
|
|
6164
|
+
/**
|
|
6165
|
+
* Optional completion-token breakdown metadata reported by the provider.
|
|
6166
|
+
*
|
|
6167
|
+
* Same caveat as `prompt_tokens_details`: provider-specific diagnostic
|
|
6168
|
+
* metadata, not a billing fact.
|
|
6169
|
+
*/
|
|
6170
|
+
completion_tokens_details?: Record<string, unknown>;
|
|
6171
|
+
/**
|
|
6172
|
+
* Optional provider-specific credit/quota diagnostic reported by some
|
|
6173
|
+
* upstream gateways. The SDK forwards it when present; it is not a
|
|
6174
|
+
* billing statement and must not be treated as authoritative cost.
|
|
6175
|
+
*/
|
|
6176
|
+
credit?: number;
|
|
6177
|
+
/**
|
|
6178
|
+
* Catch-all for additional usage-extension fields the provider may report
|
|
6179
|
+
* (e.g. cache hit/miss, region credits, tier multipliers). The SDK does
|
|
6180
|
+
* not interpret these; they are surfaced for diagnostics only.
|
|
6181
|
+
*/
|
|
6182
|
+
extra_fields?: Record<string, unknown>;
|
|
6007
6183
|
}
|
|
6008
6184
|
interface ChatCompletion {
|
|
6009
6185
|
id: string;
|
|
@@ -6013,10 +6189,59 @@ interface ChatCompletion {
|
|
|
6013
6189
|
choices: ChatCompletionChoice[];
|
|
6014
6190
|
usage?: CompletionUsage;
|
|
6015
6191
|
}
|
|
6192
|
+
/**
|
|
6193
|
+
* Streaming tool-call delta.
|
|
6194
|
+
*
|
|
6195
|
+
* In a streaming response, a tool call is split across multiple chunks.
|
|
6196
|
+
* The first chunk carrying a given `index` typically provides `id` and
|
|
6197
|
+
* `function.name`; subsequent chunks with the same `index` append
|
|
6198
|
+
* `function.arguments` fragments. All fields except `index` are optional
|
|
6199
|
+
* because any single chunk may carry only a partial fragment.
|
|
6200
|
+
*
|
|
6201
|
+
* The SDK forwards these deltas as-is; the business layer is responsible
|
|
6202
|
+
* for accumulating them by `index` and deciding when to execute.
|
|
6203
|
+
*/
|
|
6204
|
+
interface ChatCompletionChunkToolCall {
|
|
6205
|
+
/** Positional index of this tool call within the choice; required for delta assembly. */
|
|
6206
|
+
index: number;
|
|
6207
|
+
id?: string;
|
|
6208
|
+
type?: 'function';
|
|
6209
|
+
function?: {
|
|
6210
|
+
name?: string;
|
|
6211
|
+
arguments?: string;
|
|
6212
|
+
};
|
|
6213
|
+
}
|
|
6016
6214
|
interface ChatCompletionChunkDelta {
|
|
6017
6215
|
role?: ChatCompletionRole;
|
|
6018
6216
|
content?: string | null;
|
|
6019
|
-
|
|
6217
|
+
/**
|
|
6218
|
+
* Reasoning/thinking content delta reported by models that expose a
|
|
6219
|
+
* separate reasoning channel. The SDK forwards it as-is; it is not
|
|
6220
|
+
* part of the assistant's visible reply and should be accumulated
|
|
6221
|
+
* and rendered separately from `content`.
|
|
6222
|
+
*/
|
|
6223
|
+
reasoning_content?: string | null;
|
|
6224
|
+
/**
|
|
6225
|
+
* Streaming tool-call deltas. Unlike the non-streaming
|
|
6226
|
+
* `ChatCompletionToolCall`, each entry is a fragment identified by
|
|
6227
|
+
* `index`; fields other than `index` are optional.
|
|
6228
|
+
*/
|
|
6229
|
+
tool_calls?: ChatCompletionChunkToolCall[];
|
|
6230
|
+
/**
|
|
6231
|
+
* Optional legacy function-call delta placeholder. Some upstream
|
|
6232
|
+
* providers emit an empty `function_call` object as a compatibility
|
|
6233
|
+
* marker; the SDK forwards it without interpretation.
|
|
6234
|
+
*/
|
|
6235
|
+
function_call?: {
|
|
6236
|
+
name?: string;
|
|
6237
|
+
arguments?: string;
|
|
6238
|
+
} | null;
|
|
6239
|
+
/**
|
|
6240
|
+
* Optional refusal signal reported by the model. When present, the
|
|
6241
|
+
* model declined to answer; the value is a fragment of the refusal
|
|
6242
|
+
* text and should be accumulated like `content`.
|
|
6243
|
+
*/
|
|
6244
|
+
refusal?: string | null;
|
|
6020
6245
|
}
|
|
6021
6246
|
interface ChatCompletionChunkChoice {
|
|
6022
6247
|
index: number;
|
|
@@ -6036,7 +6261,9 @@ interface ChatCompletionChunk {
|
|
|
6036
6261
|
/**
|
|
6037
6262
|
* LLM Chat Completions — POST /.cloud/llm/chat/completions (#89098)
|
|
6038
6263
|
*
|
|
6039
|
-
* Supports
|
|
6264
|
+
* Supports streaming (SSE) only. The API contract requires `stream: true`;
|
|
6265
|
+
* non-streaming is not supported. The SDK rejects `stream !== true` before
|
|
6266
|
+
* any network request is issued.
|
|
6040
6267
|
*
|
|
6041
6268
|
* Uses the shared fetch injected by `WorkBuddyCloudClient` — never
|
|
6042
6269
|
* constructs its own fetch or adds Authorization/ModelHub headers.
|
|
@@ -6050,20 +6277,25 @@ declare class ChatCompletionsAPI {
|
|
|
6050
6277
|
/**
|
|
6051
6278
|
* Create a chat completion.
|
|
6052
6279
|
*
|
|
6053
|
-
*
|
|
6054
|
-
*
|
|
6055
|
-
*
|
|
6280
|
+
* The API only supports streaming. `input.stream` must be `true`;
|
|
6281
|
+
* any other value (or omitting `stream`) is rejected before a network
|
|
6282
|
+
* request is sent. Returns an async iterable of `ChatCompletionChunk`
|
|
6283
|
+
* objects decoded from the SSE stream.
|
|
6056
6284
|
*/
|
|
6057
6285
|
create(input: ChatCompletionCreateParamsStreaming): AsyncIterable<ChatCompletionChunk>;
|
|
6058
|
-
create(input:
|
|
6059
|
-
/**
|
|
6060
|
-
* Non-streaming chat completion.
|
|
6061
|
-
*/
|
|
6062
|
-
private createNonStreaming;
|
|
6286
|
+
create(input: ChatCompletionCreateParams): AsyncIterable<ChatCompletionChunk>;
|
|
6063
6287
|
/**
|
|
6064
6288
|
* Streaming chat completion — returns an async generator of chunks.
|
|
6065
6289
|
*
|
|
6066
6290
|
* Reads the SSE stream incrementally, yielding ChatCompletionChunk objects.
|
|
6291
|
+
* `stream_options` is passed through unchanged when present.
|
|
6292
|
+
*
|
|
6293
|
+
* The `X-Request-Id` response header is captured and attached (as
|
|
6294
|
+
* `requestId`) to every `CloudOpenAIError` thrown from within the stream:
|
|
6295
|
+
* `event: error`, chunk-embedded error, JSON parse failure, and missing
|
|
6296
|
+
* `[DONE]` interruption. Non-2xx HTTP errors continue to go through
|
|
6297
|
+
* `httpError`, which independently extracts `X-Request-Id`.
|
|
6298
|
+
*
|
|
6067
6299
|
* Throws CloudOpenAIError on:
|
|
6068
6300
|
* - `event: error` in the stream
|
|
6069
6301
|
* - Stream ends without `[DONE]` (gateway_stream_interrupted)
|
|
@@ -6117,14 +6349,22 @@ declare class CloudOpenAIError extends Error {
|
|
|
6117
6349
|
/**
|
|
6118
6350
|
* LLM Models — GET /.cloud/llm/models (#89098)
|
|
6119
6351
|
*
|
|
6120
|
-
* Fetches
|
|
6121
|
-
*
|
|
6122
|
-
* its explicit public fields without exposing provider routing or credentials.
|
|
6123
|
-
*
|
|
6124
|
-
* Uses the shared fetch injected by `WorkBuddyCloudClient` — never constructs
|
|
6125
|
-
* its own fetch or adds Authorization/ModelHub headers.
|
|
6352
|
+
* Fetches the browser-safe public model directory for this application,
|
|
6353
|
+
* preserving its explicit public fields for display and selection.
|
|
6126
6354
|
*/
|
|
6127
6355
|
|
|
6356
|
+
/**
|
|
6357
|
+
* Return a safe display label for a public model directory entry.
|
|
6358
|
+
*
|
|
6359
|
+
* `name` is currently required by the SDK type, but retaining the fallback
|
|
6360
|
+
* keeps UI code resilient to cached objects produced by an older SDK release.
|
|
6361
|
+
*/
|
|
6362
|
+
declare function getModelDisplayName(model: PublicLLMModel): string;
|
|
6363
|
+
/**
|
|
6364
|
+
* Return an explicitly declared capability, or `undefined` when the server
|
|
6365
|
+
* did not provide that metadata. `undefined` must not be treated as `false`.
|
|
6366
|
+
*/
|
|
6367
|
+
declare function getModelCapability(model: PublicLLMModel, capability: keyof PublicModelCapabilities): boolean | undefined;
|
|
6128
6368
|
/** LLM models namespace. */
|
|
6129
6369
|
declare class ModelsAPI {
|
|
6130
6370
|
private readonly baseUrl;
|
|
@@ -6135,8 +6375,8 @@ declare class ModelsAPI {
|
|
|
6135
6375
|
*
|
|
6136
6376
|
* `id` is the value to pass as `model` to `chat.completions.create()`.
|
|
6137
6377
|
* Optional metadata is included only when the server explicitly provides
|
|
6138
|
-
* it; absence means unknown, not unsupported. The
|
|
6139
|
-
*
|
|
6378
|
+
* it; absence means unknown, not unsupported. The actual call result
|
|
6379
|
+
* is determined by the response, not by the directory entry.
|
|
6140
6380
|
*/
|
|
6141
6381
|
list(signal?: AbortSignal): Promise<PublicLLMModel[]>;
|
|
6142
6382
|
}
|
|
@@ -6148,9 +6388,6 @@ declare class ModelsAPI {
|
|
|
6148
6388
|
* GET /.cloud/llm/models
|
|
6149
6389
|
* POST /.cloud/llm/chat/completions
|
|
6150
6390
|
*
|
|
6151
|
-
* 凭据换手在服务端完成 —— 终端用户 session 绝不透传给 ModelHub,SDK 侧不感知。
|
|
6152
|
-
* LLM 模块**不得**自行配置 ModelHub/token,只使用 client 传入的 shared fetch。
|
|
6153
|
-
*
|
|
6154
6391
|
* 公开 API:
|
|
6155
6392
|
* cloud.llm.models.list()
|
|
6156
6393
|
* cloud.llm.chat.completions.create()
|
|
@@ -6384,13 +6621,12 @@ declare class WorkBuddyCloudClient<Database = unknown> {
|
|
|
6384
6621
|
/**
|
|
6385
6622
|
* 创建 WorkBuddy Cloud 客户端。
|
|
6386
6623
|
*
|
|
6387
|
-
* `endpoint
|
|
6624
|
+
* `endpoint` 与 `publishableKey` 来自云服务开通后下发的
|
|
6388
6625
|
* `publicConfig`,都不含 envId 与 provider 凭据(设计文档 §5.2)。
|
|
6389
6626
|
*
|
|
6390
6627
|
* ```ts
|
|
6391
6628
|
* const cloud = createWorkBuddyCloud({
|
|
6392
6629
|
* endpoint: 'https://my-app.workbuddy.link',
|
|
6393
|
-
* oauthRelayBaseUrl: 'https://api.workbuddy.cn/v2/as/genie-baas/oauth',
|
|
6394
6630
|
* publishableKey: 'wbpk_wbapp_demo_abc123',
|
|
6395
6631
|
* });
|
|
6396
6632
|
*
|
|
@@ -6496,4 +6732,4 @@ type SessionTokenProvider = () => Promise<string | undefined>;
|
|
|
6496
6732
|
/** 恒定匿名的 provider,供 auth 模块自身使用(见 createCloudFetch 的死锁说明)。 */
|
|
6497
6733
|
declare const anonymousTokenProvider: SessionTokenProvider;
|
|
6498
6734
|
|
|
6499
|
-
export { AuthModule, type AuthModuleOptions, type AuthStateChangeCallback, type AuthStateChangeEvent, CLOUD_MODULE_PATHS, CLOUD_PATH_PREFIX, type ChatCompletion, type ChatCompletionAssistantMessage, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type
|
|
6735
|
+
export { AuthModule, type AuthModuleOptions, type AuthStateChangeCallback, type AuthStateChangeEvent, CLOUD_MODULE_PATHS, CLOUD_PATH_PREFIX, type ChatCompletion, type ChatCompletionAssistantMessage, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionChunkChoice, type ChatCompletionChunkDelta, type ChatCompletionChunkToolCall, type ChatCompletionContentPart, type ChatCompletionCreateParams, type ChatCompletionCreateParamsStreaming, type ChatCompletionMessage, type ChatCompletionRequestMessage, type ChatCompletionResponseFormat, type ChatCompletionRole, type ChatCompletionTool, type ChatCompletionToolCall, type ChatCompletionToolChoice, type CloudAuthEvent, type CloudAuthStateCallback, type CloudAuthStorage, type CloudError, type CloudErrorKind, type CloudModuleName, type CloudOAuthProvider, CloudOpenAIError, type CloudOpenAIErrorInit, type CloudResult, type CloudRuntimeConfig, type CloudSession, type CloudStorageCursorFolder, type CloudStorageCursorListOptions, type CloudStorageCursorObject, type CloudStorageError, type CloudStorageFile, type CloudStorageFileBody, type CloudStorageFileOptions, type CloudStorageListOptions, type CloudStorageListResult, type CloudStorageMetadata, type CloudStorageObjectInfo, CloudStoragePathError, type CloudStorageResult, type CloudUser, type CompletionUsage, DEFAULT_SIGNED_URL_TTL_SECONDS, LlmModule, MAX_SIGNED_URL_TTL_SECONDS, type OAuthCredentials, type OAuthRedirect, type OAuthSignInOptions, type OAuthStartResult, type OpenAIErrorObject, type OtpChallenge, type OtpCredentials, type OtpSignInChallenge, type OtpVerifyCredentials, PUBLISHABLE_KEY_HEADER, type PasswordCredentials, type PasswordResetChallenge, type PasswordResetUpdate, type PublicLLMModel, type PublicModelCapabilities, type PublicModelModalities, type PublicModelPricing, type PublicModelReasoning, RUNTIME_STORAGE_BUCKET, type ResetPasswordWithOldCredentials, type SessionTokenProvider, type SignUpCredentials, type VerifyOtpParams, WorkBuddyCloudClient, WorkBuddyCloudConfigError, type WorkBuddyCloudOptions, WorkBuddyDatabaseModule, WorkBuddyStorageBucket, WorkBuddyStorageDownload, WorkBuddyStorageModule, anonymousTokenProvider, createMemoryStorage, createWorkBuddyCloud, getModelCapability, getModelDisplayName, shouldClearCredentials };
|