@zqagent/shared 0.0.0-stage → 0.1.0

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.
Files changed (73) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +21 -2
  3. package/dist/approval-view.cjs +99 -0
  4. package/dist/approval-view.cjs.map +1 -0
  5. package/dist/approval-view.d.cts +39 -0
  6. package/dist/approval-view.d.ts +39 -0
  7. package/dist/approval-view.js +69 -0
  8. package/dist/approval-view.js.map +1 -0
  9. package/dist/fleet.cjs +263 -0
  10. package/dist/fleet.cjs.map +1 -0
  11. package/dist/fleet.d.cts +284 -0
  12. package/dist/fleet.d.ts +284 -0
  13. package/dist/fleet.js +214 -0
  14. package/dist/fleet.js.map +1 -0
  15. package/dist/hub-api.cjs +901 -0
  16. package/dist/hub-api.cjs.map +1 -0
  17. package/dist/hub-api.d.cts +1677 -0
  18. package/dist/hub-api.d.ts +1677 -0
  19. package/dist/hub-api.js +776 -0
  20. package/dist/hub-api.js.map +1 -0
  21. package/dist/index-DokiNlGJ.d.cts +182 -0
  22. package/dist/index-DokiNlGJ.d.ts +182 -0
  23. package/dist/index.cjs +861 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +7 -0
  26. package/dist/index.d.ts +7 -0
  27. package/dist/index.js +779 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/llm-presets.cjs +92 -0
  30. package/dist/llm-presets.cjs.map +1 -0
  31. package/dist/llm-presets.d.cts +28 -0
  32. package/dist/llm-presets.d.ts +28 -0
  33. package/dist/llm-presets.js +66 -0
  34. package/dist/llm-presets.js.map +1 -0
  35. package/dist/media.cjs +111 -0
  36. package/dist/media.cjs.map +1 -0
  37. package/dist/media.d.cts +59 -0
  38. package/dist/media.d.ts +59 -0
  39. package/dist/media.js +79 -0
  40. package/dist/media.js.map +1 -0
  41. package/dist/messages-CiXjdR1Z.d.cts +257 -0
  42. package/dist/messages-CiXjdR1Z.d.ts +257 -0
  43. package/dist/model-capabilities.cjs +105 -0
  44. package/dist/model-capabilities.cjs.map +1 -0
  45. package/dist/model-capabilities.d.cts +46 -0
  46. package/dist/model-capabilities.d.ts +46 -0
  47. package/dist/model-capabilities.js +74 -0
  48. package/dist/model-capabilities.js.map +1 -0
  49. package/dist/notify/index.cjs +375 -0
  50. package/dist/notify/index.cjs.map +1 -0
  51. package/dist/notify/index.d.cts +2 -0
  52. package/dist/notify/index.d.ts +2 -0
  53. package/dist/notify/index.js +330 -0
  54. package/dist/notify/index.js.map +1 -0
  55. package/dist/secrets.cjs +121 -0
  56. package/dist/secrets.cjs.map +1 -0
  57. package/dist/secrets.d.cts +25 -0
  58. package/dist/secrets.d.ts +25 -0
  59. package/dist/secrets.js +82 -0
  60. package/dist/secrets.js.map +1 -0
  61. package/dist/wire/index.cjs +1163 -0
  62. package/dist/wire/index.cjs.map +1 -0
  63. package/dist/wire/index.d.cts +166 -0
  64. package/dist/wire/index.d.ts +166 -0
  65. package/dist/wire/index.js +1081 -0
  66. package/dist/wire/index.js.map +1 -0
  67. package/dist/wire/node.cjs +224 -0
  68. package/dist/wire/node.cjs.map +1 -0
  69. package/dist/wire/node.d.cts +14 -0
  70. package/dist/wire/node.d.ts +14 -0
  71. package/dist/wire/node.js +195 -0
  72. package/dist/wire/node.js.map +1 -0
  73. package/package.json +99 -3
@@ -0,0 +1,1677 @@
1
+ import { FleetNodeStats, SessionStateEntry, FleetCredential } from './fleet.cjs';
2
+
3
+ /**
4
+ * Hub REST 客户端(浏览器/桌面共用,纯 fetch,无 Node 依赖)
5
+ *
6
+ * 账号/节点管理/节点/指令代理/消息/事件流。浏览器只持会话令牌,节点密钥留在 Hub。
7
+ * 供 packages/portal(统一控制台:桌面壳内嵌 + 浏览器用户中心)复用。
8
+ */
9
+
10
+ /**
11
+ * 列表排序键:任务请求开始时间优先,旧数据(该字段上线前)回退完成时间。
12
+ *
13
+ * 工作台的节点 / 项目 / 任务三处列表统一用它倒序,保证「最近在跑什么」排最前。
14
+ * 返回空串表示这个条目从没跑过任务,倒序时自然落到最后。
15
+ */
16
+ declare function activityKey(o: {
17
+ lastStartedAt?: string | null;
18
+ lastCompletedAt?: string | null;
19
+ }): string;
20
+ /**
21
+ * 按最近一次任务请求的开始时间倒序(最新的在前)。
22
+ *
23
+ * `tieBreak` 只在时间完全相同时使用(如从没跑过的条目之间),保证顺序稳定、
24
+ * 刷新不会跳动。
25
+ */
26
+ declare function compareByActivity<T extends {
27
+ lastStartedAt?: string | null;
28
+ lastCompletedAt?: string | null;
29
+ }>(a: T, b: T, tieBreak?: (x: T, y: T) => number): number;
30
+ declare function setHubBaseResolver(fn: ((baseUrl: string) => string) | null): void;
31
+ interface HubFleetSummary {
32
+ id: string;
33
+ name: string;
34
+ /** 系统内置「未分组」 */
35
+ ungrouped?: boolean;
36
+ nodeCount: number;
37
+ createdAt: string;
38
+ }
39
+ /** 节点级汇总统计(节点 info 上报) */
40
+ interface HubNodeTotals {
41
+ projects: number;
42
+ sessions: number;
43
+ running: number;
44
+ waiting: number;
45
+ }
46
+ interface HubNodeSummary {
47
+ nodeId: string;
48
+ label?: string;
49
+ /** 计费状态;suspended = 余额不足暂停(缺省视为可用) */
50
+ billingStatus?: "active" | "suspended";
51
+ billingSuspendedReason?: "insufficient";
52
+ online: boolean;
53
+ lastSeen?: string;
54
+ platform?: string;
55
+ mode?: string;
56
+ version?: string;
57
+ /** 节点自报主 IP(新版节点上报;旧版缺省) */
58
+ ip?: string;
59
+ projects: Array<{
60
+ id: string;
61
+ name: string;
62
+ sessionCount?: number;
63
+ running?: number;
64
+ waiting?: number;
65
+ /** 项目工作目录(节点上报;旧版节点缺省) */
66
+ workspaceRoot?: string | null;
67
+ }>;
68
+ /** 项目/会话汇总(新版节点上报;旧版为 null) */
69
+ totals?: HubNodeTotals | null;
70
+ /**
71
+ * 会话状态快照(只含 projectId / sessionId / name / status)。
72
+ *
73
+ * 工作台/节点首页用它建立初始视图,之后的变更由账号级 WSS 的
74
+ * `session_status` 通知增量推送。明细(消息/模型/token)不在这里。
75
+ */
76
+ sessions?: SessionStateEntry[] | null;
77
+ /** 累计运行统计(新版节点上报;旧版为 null) */
78
+ stats?: FleetNodeStats | null;
79
+ /**
80
+ * 该节点下任一任务最近一次请求的开始时间(节点列表按它倒序)。
81
+ * 从未发起过任务时为 null(旧版节点也不上报)。
82
+ */
83
+ lastStartedAt?: string | null;
84
+ }
85
+ /** 节点详情(含节点管理归属与创建时间) */
86
+ interface HubNodeDetail extends HubNodeSummary {
87
+ fleetId: string;
88
+ fleetName: string;
89
+ createdAt: string;
90
+ /** 访问身份:owner = 自己的节点,operator = 别人共享给我 */
91
+ access?: HubNodeAccessView;
92
+ }
93
+ /** 当前账号对某节点的访问身份 */
94
+ interface HubNodeAccessView {
95
+ role: "owner" | "operator";
96
+ /** 共享到期时刻(ISO);owner 为 null */
97
+ expiresAt: string | null;
98
+ /** 共享期间是否允许消耗所有者的模型额度 */
99
+ allowModelSpend: boolean;
100
+ /** 所有者账号(掩码);owner 自己看时为空串 */
101
+ ownerLabel?: string;
102
+ }
103
+ /** 共享给我的节点(列表项,形状与节点摘要对齐并附加授权信息) */
104
+ interface HubSharedNode extends HubNodeSummary {
105
+ fleetId: string;
106
+ fleetName: string;
107
+ ownerLabel: string;
108
+ grantId: string;
109
+ expiresAt: string;
110
+ allowModelSpend: boolean;
111
+ }
112
+ /** 共享授权(owner 视角) */
113
+ interface HubNodeGrantView {
114
+ id: string;
115
+ nodeId: string;
116
+ toUser: {
117
+ id: string;
118
+ label: string;
119
+ };
120
+ role: "operator";
121
+ allowModelSpend: boolean;
122
+ expiresAt: string;
123
+ status: "active" | "expired" | "revoked";
124
+ createdAt: string;
125
+ revokedAt: string | null;
126
+ revokedReason: "owner" | "self" | "node_deleted" | "account_deleted" | null;
127
+ }
128
+ /**
129
+ * 我共享出去的授权(跨节点聚合,设备列表用)。
130
+ *
131
+ * 与 `HubNodeGrantView` 的区别:多带节点名与分组名,便于在「设备」列表里
132
+ * 直接给出「哪台机器 · 共享给谁 · 何时共享 · 何时到期」,不用再逐个节点查。
133
+ * 已撤销的授权不在列表里(节点删除会级联撤销)。
134
+ */
135
+ interface HubOutgoingGrant {
136
+ nodeId: string;
137
+ /** 节点名;节点从未命名时为 null(前端回退显示 nodeId) */
138
+ label: string | null;
139
+ fleetId: string;
140
+ fleetName: string;
141
+ grantId: string;
142
+ toUser: {
143
+ id: string;
144
+ label: string;
145
+ };
146
+ allowModelSpend: boolean;
147
+ /** 共享时间(首次授权时刻;延长不会刷新它) */
148
+ createdAt: string;
149
+ /** 到期时刻(ISO,绝对时间) */
150
+ expiresAt: string;
151
+ /** 只区分生效 / 已过期:已撤销的不返回 */
152
+ status: "active" | "expired";
153
+ }
154
+ /** 节点操作记录的一条 */
155
+ interface HubNodeActivityItem {
156
+ id: string;
157
+ ts: string;
158
+ nodeId: string;
159
+ actor: {
160
+ userId: string;
161
+ label: string;
162
+ /**
163
+ * 以什么身份操作:owner = 节点所有者,operator = 共享接收者。
164
+ * unknown = actor 账号已不存在(或回写时无法解析),前端据此不臆断身份。
165
+ */
166
+ via: "owner" | "operator" | "unknown";
167
+ };
168
+ action: string;
169
+ /** 服务端兜底摘要(前端优先按 action + 结构化字段自行渲染多语言文案) */
170
+ summary: string;
171
+ commandType: string | null;
172
+ projectId: string | null;
173
+ sessionId: string | null;
174
+ result: "ok" | "denied" | "error";
175
+ /**
176
+ * 本条动作的对象补充,按 action 取值:
177
+ * - rename_node / rename_node_self:新名称
178
+ * - move_node:移动到的分组名
179
+ * - grant_create / grant_extend / grant_revoke / grant_leave:被授权的账号(已掩码)
180
+ */
181
+ target: string | null;
182
+ /** 发起客户端(web / desktop / cli…);旧记录为 null */
183
+ client: string | null;
184
+ /** 命令级记录的请求 ID(排障时对得上节点日志);非命令记录为 null */
185
+ reqId: string | null;
186
+ }
187
+ /** 项目总览里的单条任务(会话) */
188
+ interface HubProjectTask {
189
+ sessionId: string;
190
+ name: string | null;
191
+ status: string;
192
+ lastUserMessage: string | null;
193
+ /** 该任务最近一次请求的开始时间(排序键) */
194
+ lastStartedAt: string | null;
195
+ lastCompletedAt: string | null;
196
+ }
197
+ /** 项目总览行:跨节点聚合的项目视图 */
198
+ interface HubProjectRow {
199
+ projectId: string;
200
+ name: string;
201
+ workspaceRoot: string | null;
202
+ nodeId: string;
203
+ nodeLabel: string;
204
+ fleetId: string;
205
+ fleetName: string;
206
+ online: boolean;
207
+ sessionCount: number;
208
+ running: number;
209
+ waiting: number;
210
+ /** 该项目下所有任务里最近一次请求的开始时间(列表按它倒序) */
211
+ lastStartedAt: string | null;
212
+ /** 该项目下所有任务最近一次成功完成的时刻(ISO 8601;从未完成时 null) */
213
+ lastCompletedAt: string | null;
214
+ /** 任务总数(tasks 最多回传前 20 条) */
215
+ taskCount: number;
216
+ tasks: HubProjectTask[];
217
+ }
218
+ /** 项目总览分页响应 */
219
+ interface HubProjectPage {
220
+ total: number;
221
+ items: HubProjectRow[];
222
+ }
223
+ /** 任务总览行:跨节点聚合的会话视图(数据来自 Hub 保存的节点快照) */
224
+ interface HubTaskRow {
225
+ sessionId: string;
226
+ name: string | null;
227
+ status: string;
228
+ lastUserMessage: string | null;
229
+ /** 该任务最近一次请求的开始时间(列表按它倒序) */
230
+ lastStartedAt: string | null;
231
+ lastCompletedAt: string | null;
232
+ projectId: string;
233
+ projectName: string;
234
+ nodeId: string;
235
+ nodeLabel: string;
236
+ fleetId: string;
237
+ fleetName: string;
238
+ online: boolean;
239
+ }
240
+ /** 任务筛选口径的计数(始终基于全部任务,不受筛选影响) */
241
+ interface HubTaskCounts {
242
+ all: number;
243
+ running: number;
244
+ waiting: number;
245
+ error: number;
246
+ completed: number;
247
+ }
248
+ /** 任务总览分页响应 */
249
+ interface HubTaskPage {
250
+ total: number;
251
+ counts: HubTaskCounts;
252
+ items: HubTaskRow[];
253
+ }
254
+ interface HubPlan {
255
+ id: "free" | "pro" | "team";
256
+ name: string;
257
+ priceMonthly: number;
258
+ priceYearly: number;
259
+ limits: {
260
+ maxNodes: number;
261
+ maxFleets: number;
262
+ notifications: boolean;
263
+ historyDays: number;
264
+ };
265
+ }
266
+ interface HubSubscriptionView {
267
+ plan: string;
268
+ planExpiresAt: string | null;
269
+ limits: {
270
+ maxNodes: number;
271
+ maxFleets: number;
272
+ notifications: boolean;
273
+ historyDays: number;
274
+ };
275
+ usage: {
276
+ fleets: number;
277
+ nodes: number;
278
+ };
279
+ }
280
+ interface HubOrderView {
281
+ id: string;
282
+ plan: string;
283
+ period: string;
284
+ amount: number;
285
+ provider: string;
286
+ status: string;
287
+ createdAt: string;
288
+ paidAt?: string;
289
+ /** plan=套餐(已停售);wallet/api_topup=账户充值 */
290
+ purpose?: "plan" | "wallet" | "api_topup";
291
+ }
292
+ interface HubUserView {
293
+ id: string;
294
+ email: string | null;
295
+ phone: string | null;
296
+ /** 可选昵称(仅展示;缺省时前端回退到邮箱/手机号) */
297
+ nickname?: string | null;
298
+ /** 可选头像(`data:image/...;base64,...`,客户端已裁成 256×256) */
299
+ avatar?: string | null;
300
+ plan: string;
301
+ /** 是否已设置可用密码(短信登录自动注册后为 false) */
302
+ passwordSet?: boolean;
303
+ /** 系统管理员角色(缺省 user);仅 admin 可进入 /admin */
304
+ role?: "user" | "admin";
305
+ /** 账号状态(缺省 active) */
306
+ status?: "active" | "disabled" | "deleted";
307
+ }
308
+ interface HubCaptchaView {
309
+ captchaId: string;
310
+ svg: string;
311
+ /** 仅调试模式返回(HUB_SMS_DEBUG=1) */
312
+ debugCode?: string;
313
+ }
314
+ type HubSmsPurpose = "register" | "login" | "reset";
315
+ interface HubAuthInput {
316
+ email?: string;
317
+ phone?: string;
318
+ password?: string;
319
+ code?: string;
320
+ emailCode?: string;
321
+ /** 注册时可选填写的昵称(最长 32 个字符;之后可在个人中心修改) */
322
+ nickname?: string;
323
+ }
324
+ interface HubPairingView {
325
+ /** 对外可达的网关 wss 地址(节点凭此直连 Rust 网关;Hub 未配置时为缺省) */
326
+ gatewayUrl?: string;
327
+ fleetToken: string;
328
+ fleetSecret: string;
329
+ expiresAt?: string;
330
+ }
331
+ interface HubEnrollmentView {
332
+ code: string;
333
+ expiresAt: string;
334
+ }
335
+ interface HubNotificationView {
336
+ id: string;
337
+ userId: string;
338
+ type: string;
339
+ title: string;
340
+ body?: string;
341
+ link?: string;
342
+ readAt?: string;
343
+ createdAt: string;
344
+ }
345
+ declare function hubRegister(baseUrl: string, email: string, password: string): Promise<{
346
+ token: string;
347
+ }>;
348
+ /** 注册(邮箱或手机号;手机号需先获取短信验证码;可选填写昵称) */
349
+ declare function hubRegisterAccount(baseUrl: string, input: HubAuthInput): Promise<{
350
+ token: string;
351
+ user?: HubUserView;
352
+ }>;
353
+ declare function hubLogin(baseUrl: string, email: string, password: string): Promise<{
354
+ token: string;
355
+ }>;
356
+ /** 登录(邮箱+密码,或手机号+密码/短信验证码;手机号验证码登录未注册时自动注册) */
357
+ declare function hubLoginAccount(baseUrl: string, input: HubAuthInput): Promise<{
358
+ token: string;
359
+ user?: HubUserView;
360
+ autoRegistered?: boolean;
361
+ }>;
362
+ /** 图形验证码(发送短信前必填) */
363
+ declare function hubCaptcha(baseUrl: string): Promise<HubCaptchaView>;
364
+ /** 发送短信验证码(purpose:register/login/reset;本机当天第 4 次起需图形验证码) */
365
+ declare function hubSendSms(baseUrl: string, input: {
366
+ phone: string;
367
+ purpose: HubSmsPurpose;
368
+ captchaId?: string;
369
+ captcha?: string;
370
+ /** 本机设备标识(登录页持久化生成);缺省时服务端按出口 IP 计数 */
371
+ clientId?: string;
372
+ }): Promise<{
373
+ sent: boolean;
374
+ expiresIn: number;
375
+ debugCode?: string;
376
+ }>;
377
+ /** 验证码发送状态:本机当天已发次数与本次是否需要图形验证码 */
378
+ interface HubSendCodeStatus {
379
+ captchaRequired: boolean;
380
+ /** 本机今天已发送次数 */
381
+ used: number;
382
+ /** 本机今天还能免图形验证码发送的次数 */
383
+ remaining: number;
384
+ }
385
+ /**
386
+ * 查询发送状态(决定登录/注册/找回密码页是否显示图形验证码)。
387
+ *
388
+ * 计数维度是本机设备标识 + 自然日,与手机号、邮箱无关。
389
+ */
390
+ declare function hubSendCodeStatus(baseUrl: string, clientId?: string): Promise<HubSendCodeStatus>;
391
+ /**
392
+ * 短信发送状态(旧接口,兼容既有调用)。
393
+ *
394
+ * 与 `hubSendCodeStatus` 等价,只是沿用 `/auth/sms/status` 路径。
395
+ */
396
+ declare function hubSmsStatus(baseUrl: string, phone: string, clientId?: string): Promise<HubSendCodeStatus>;
397
+ /** 发送邮箱验证码(注册校验 / 找回密码;策略与短信一致) */
398
+ declare function hubSendEmailCode(baseUrl: string, input: {
399
+ email: string;
400
+ /** 缺省 register;reset 用于找回密码(要求邮箱已注册) */
401
+ purpose?: "register" | "reset";
402
+ /** 仅在本机当天第 4 次起需要 */
403
+ captchaId?: string;
404
+ captcha?: string;
405
+ /** 本机设备标识;缺省时服务端按出口 IP 计数 */
406
+ clientId?: string;
407
+ }): Promise<{
408
+ sent: boolean;
409
+ expiresIn: number;
410
+ debugCode?: string;
411
+ }>;
412
+ /** 忘记密码:手机号 + 短信验证码,或邮箱 + 邮箱验证码 */
413
+ declare function hubResetPassword(baseUrl: string, input: {
414
+ phone?: string;
415
+ email?: string;
416
+ code: string;
417
+ newPassword: string;
418
+ }): Promise<{
419
+ changed: boolean;
420
+ }>;
421
+ /** 当前用户(id/email/nickname/生效套餐) */
422
+ declare function hubMe(baseUrl: string, token: string): Promise<HubUserView>;
423
+ /**
424
+ * 更新个人资料(昵称 / 头像)。
425
+ *
426
+ * 字段按需更新:不传的字段保持原样。`nickname` / `avatar` 传空串或 `null` 表示清除。
427
+ */
428
+ declare function hubUpdateProfile(baseUrl: string, token: string, input: {
429
+ nickname?: string;
430
+ avatar?: string | null;
431
+ }): Promise<{
432
+ nickname: string | null;
433
+ avatar?: string | null;
434
+ }>;
435
+ /** 网关账号级订阅涉及的节点(nodeId → 归属节点管理) */
436
+ interface HubGatewayFleet {
437
+ id: string;
438
+ nodes: string[];
439
+ }
440
+ /** 账号级实时通道的网关凭据(M5:控制台/用户中心直连 Rust 网关) */
441
+ interface HubGatewayCredentialView {
442
+ /** 对外可达的网关 wss 地址 */
443
+ url: string;
444
+ /**
445
+ * 已签名终端令牌(scope = 本人全部节点)。
446
+ *
447
+ * `null` 表示账号下没有任何节点——不必建连接(网关会拒绝空 scope 的令牌)。
448
+ */
449
+ credential: {
450
+ /** base64(wire `Auth`),原样作为 AUTH 帧载荷 */
451
+ auth: string;
452
+ /** 过期时刻(毫秒) */
453
+ expires: number;
454
+ scope: string[];
455
+ kind: "terminal";
456
+ client: string;
457
+ } | null;
458
+ fleets: HubGatewayFleet[];
459
+ }
460
+ /** 单节点终端凭据(`POST .../terminal-credential` 的返回体) */
461
+ interface HubTerminalCredential {
462
+ /** 对外可达的网关 wss 地址(与令牌一并返回,客户端一次请求即可建连) */
463
+ url: string;
464
+ /** base64(wire `Auth`),原样作为 AUTH 帧载荷 */
465
+ auth: string;
466
+ expires: number;
467
+ scope: string[];
468
+ kind: "terminal";
469
+ client: string;
470
+ }
471
+ /**
472
+ * 获取**单个节点**的终端网关凭据(节点控制台页用)。
473
+ *
474
+ * 与 `hubRealtimeCredential`(账号级,覆盖本人全部节点)的区别是授权范围:
475
+ * 这里只授权该节点,最小权限。
476
+ */
477
+ declare function hubTerminalCredential(baseUrl: string, token: string, fleetId: string, nodeId: string, client?: string): Promise<HubTerminalCredential>;
478
+ /**
479
+ * 获取账号级终端网关凭据。
480
+ *
481
+ * 取代从前那套 broker 直连账号:令牌授权范围
482
+ * = 本人全部节点,供账号级实时通道一条 WSS 订阅所有节点。
483
+ */
484
+ declare function hubRealtimeCredential(baseUrl: string, token: string, client?: string): Promise<HubGatewayCredentialView>;
485
+ /** 修改密码(手机号账号需短信验证码,可附原密码) */
486
+ declare function hubChangePassword(baseUrl: string, token: string, input: {
487
+ oldPassword?: string;
488
+ newPassword: string;
489
+ code?: string;
490
+ }): Promise<{
491
+ changed: boolean;
492
+ }>;
493
+ declare function hubListFleets(baseUrl: string, token: string): Promise<HubFleetSummary[]>;
494
+ declare function hubCreateFleet(baseUrl: string, token: string, name: string): Promise<HubFleetSummary>;
495
+ declare function hubDeleteFleet(baseUrl: string, token: string, fleetId: string): Promise<void>;
496
+ /** 重命名分组 */
497
+ declare function hubUpdateFleet(baseUrl: string, token: string, fleetId: string, name: string): Promise<HubFleetSummary>;
498
+ /** 节点管理配对凭据(网关地址 + fleetToken/fleetSecret,供手工接入节点) */
499
+ declare function hubFleetPairing(baseUrl: string, token: string, fleetId: string): Promise<HubPairingView>;
500
+ /** 生成一次性注册码(15 分钟有效) */
501
+ declare function hubCreateEnrollment(baseUrl: string, token: string, fleetId: string): Promise<HubEnrollmentView>;
502
+ declare function hubListNodes(baseUrl: string, token: string, fleetId: string): Promise<HubNodeSummary[]>;
503
+ /** 项目总览(跨节点聚合,按最后完成任务时间倒序分页;`q` 按项目 / 节点 / 路径模糊过滤) */
504
+ declare function hubListProjects(baseUrl: string, token: string, opts?: {
505
+ limit?: number;
506
+ offset?: number;
507
+ q?: string;
508
+ }): Promise<HubProjectPage>;
509
+ /**
510
+ * 任务总览(跨节点聚合,按需要人处理 / 运行中 / 完成时间排序分页)。
511
+ *
512
+ * `status` 与工作台筛选条一致:all / running / waiting / error / completed。
513
+ * `q` 按任务名 / 项目 / 节点 / 最近消息模糊过滤(服务端过滤,分页与总数才准确)。
514
+ */
515
+ declare function hubListTasks(baseUrl: string, token: string, opts?: {
516
+ limit?: number;
517
+ offset?: number;
518
+ status?: string;
519
+ q?: string;
520
+ }): Promise<HubTaskPage>;
521
+ /** 单节点详情(状态/统计/项目/归属) */
522
+ declare function hubGetNode(baseUrl: string, token: string, fleetId: string, nodeId: string): Promise<HubNodeDetail>;
523
+ /**
524
+ * 单节点详情(不依赖 fleetId 的统一入口)。
525
+ *
526
+ * 共享成员手里只有 nodeId + owner 的 fleetId(从共享列表拿到);新代码用这条,
527
+ * 避免为了读详情先拼一条自己无权访问的 fleet 路径。
528
+ */
529
+ declare function hubGetNodeById(baseUrl: string, token: string, nodeId: string): Promise<HubNodeDetail>;
530
+ /** 共享给我的节点列表 */
531
+ declare function hubSharedNodes(baseUrl: string, token: string): Promise<HubSharedNode[]>;
532
+ /**
533
+ * 我共享出去的授权列表(跨节点聚合)。
534
+ *
535
+ * 只返回未撤销的授权(生效中 + 已过期),供设备列表展示「共享给谁、何时
536
+ * 共享、何时到期」;要撤销仍需走单节点的 `hubRevokeNodeGrant`。
537
+ */
538
+ declare function hubOutgoingGrants(baseUrl: string, token: string): Promise<HubOutgoingGrant[]>;
539
+ /** 共享授权列表(仅节点所有者可调) */
540
+ declare function hubListNodeGrants(baseUrl: string, token: string, fleetId: string, nodeId: string): Promise<HubNodeGrantView[]>;
541
+ /**
542
+ * 新建 / 延长共享授权。
543
+ *
544
+ * `expiresAt` 为 ISO 字符串(前端 datetime-local 给出,**精确到分**);
545
+ * `expiresInDays` 是快捷天数(两者二选一,服务端统一收敛为绝对时刻)。
546
+ * 同一账号重复授权 = 延长,不会产生第二条记录。
547
+ */
548
+ declare function hubCreateNodeGrant(baseUrl: string, token: string, fleetId: string, nodeId: string, input: {
549
+ account: string;
550
+ expiresAt?: string;
551
+ expiresInDays?: number;
552
+ allowModelSpend?: boolean;
553
+ }): Promise<{
554
+ grant: HubNodeGrantView;
555
+ }>;
556
+ /** 撤销共享授权(仅节点所有者) */
557
+ declare function hubRevokeNodeGrant(baseUrl: string, token: string, fleetId: string, nodeId: string, grantId: string): Promise<{
558
+ revoked: boolean;
559
+ }>;
560
+ /** 退出共享(被授权人主动放弃) */
561
+ declare function hubLeaveSharedNode(baseUrl: string, token: string, nodeId: string): Promise<{
562
+ left: boolean;
563
+ }>;
564
+ /**
565
+ * 节点操作记录(owner 与共享成员看到**同一份**)。
566
+ *
567
+ * 命令级条目由网关回写(`GATEWAY_HUB_ACTIVITY_URL`);未配置时只有控制面操作
568
+ * (改名/挪组/进入控制台/共享关系变更)。
569
+ */
570
+ declare function hubNodeActivity(baseUrl: string, token: string, nodeId: string, opts?: {
571
+ limit?: number;
572
+ offset?: number;
573
+ }): Promise<{
574
+ total: number;
575
+ items: HubNodeActivityItem[];
576
+ }>;
577
+ declare function hubEnrollNode(baseUrl: string, token: string, fleetId: string, nodeId: string, label?: string): Promise<void>;
578
+ /**
579
+ * 凭一次性注册码接入节点管理(公开接口,无需登录令牌)。
580
+ *
581
+ * 成功后返回节点管理密钥与网关地址,供节点写入 `fleet.json` 并连接。
582
+ * 注册码一次性、短时有效;同一 nodeId 不可被其他节点管理纳管(防抢注)。
583
+ */
584
+ declare function hubEnrollByCode(baseUrl: string, input: {
585
+ code: string;
586
+ nodeId: string;
587
+ label?: string;
588
+ }): Promise<FleetCredential>;
589
+ /**
590
+ * 凭 Hub 账号接入节点(公开接口,无需令牌)。
591
+ *
592
+ * 节点首次启动时交互式输入账号,校验通过即领取节点管理密钥并绑定 nodeId;
593
+ * 节点默认归入内置「未分组」(分组为空的节点在控制台集中显示)。
594
+ */
595
+ declare function hubEnrollByAccount(baseUrl: string, input: {
596
+ email?: string;
597
+ phone?: string;
598
+ password?: string;
599
+ code?: string;
600
+ nodeId: string;
601
+ label?: string;
602
+ }): Promise<FleetCredential>;
603
+ /**
604
+ * 凭「已登录的 Hub 令牌」接入节点(需登录)。
605
+ *
606
+ * 桌面端在用户登录成功后调用。相比 `/enroll/account` 的优势:短信验证码
607
+ * 登录时验证码已被消费,无法再拿它校验一次;而登录令牌在手,就能直接换取
608
+ * 节点管理凭据——「登录后本机自动接入、可直接用内置模型」因此覆盖所有登录方式。
609
+ */
610
+ declare function hubEnrollByToken(baseUrl: string, token: string, input: {
611
+ nodeId: string;
612
+ label?: string;
613
+ }): Promise<FleetCredential>;
614
+ declare function hubDeleteNode(baseUrl: string, token: string, fleetId: string, nodeId: string): Promise<void>;
615
+ /** 重命名节点:Hub 更新 label 并下发节点写入本地配置 */
616
+ declare function hubUpdateNode(baseUrl: string, token: string, fleetId: string, nodeId: string, label: string): Promise<{
617
+ nodeId: string;
618
+ label: string | null;
619
+ }>;
620
+ /**
621
+ * 节点自助改名:节点用自身的 fleetToken 鉴权,把显示名写进 Hub 记录。
622
+ *
623
+ * 与 `hubUpdateNode`(用户令牌)落在同一份数据上,区别只是鉴权主体:
624
+ * 本机没登录 Hub 用户态时(`zqagent rename`),节点只能凭自己的凭据改。
625
+ */
626
+ declare function hubUpdateNodeLabelSelf(baseUrl: string, fleetToken: string, input: {
627
+ nodeId: string;
628
+ label: string;
629
+ }): Promise<{
630
+ nodeId: string;
631
+ label: string;
632
+ }>;
633
+ /** 将节点移动到目标分组(仅改 Hub 记录;分组是控制面元数据,无需下发节点) */
634
+ declare function hubMoveNode(baseUrl: string, token: string, fleetId: string, nodeId: string, targetFleetId: string): Promise<{
635
+ nodeId: string;
636
+ fleetId: string;
637
+ }>;
638
+ /** 套餐列表(公开) */
639
+ declare function hubPlans(baseUrl: string): Promise<HubPlan[]>;
640
+ /** 当前订阅(套餐/到期/限额/用量) */
641
+ declare function hubSubscription(baseUrl: string, token: string): Promise<HubSubscriptionView>;
642
+ /** 可用支付渠道 */
643
+ declare function hubChannels(baseUrl: string, token: string): Promise<Array<{
644
+ name: string;
645
+ configured: boolean;
646
+ aggregate?: boolean;
647
+ }>>;
648
+ /** 我的订单 */
649
+ declare function hubOrders(baseUrl: string, token: string): Promise<HubOrderView[]>;
650
+ /**
651
+ * 主动同步订单状态。
652
+ *
653
+ * 扫码支付后前端轮询这里:回调可能丢失或延迟,后端会向渠道查询真实状态
654
+ * 并在支付成功时完成入账。
655
+ */
656
+ declare function hubSyncOrder(baseUrl: string, token: string, orderId: string): Promise<{
657
+ order: HubOrderView;
658
+ paid: boolean;
659
+ }>;
660
+ /** 站内消息列表(含未读数) */
661
+ declare function hubNotifications(baseUrl: string, token: string, limit?: number): Promise<{
662
+ items: HubNotificationView[];
663
+ unread: number;
664
+ }>;
665
+ /** 标记站内消息已读(all=true 或指定 ids) */
666
+ declare function hubMarkNotificationsRead(baseUrl: string, token: string, input: {
667
+ ids?: string[];
668
+ all?: boolean;
669
+ }): Promise<{
670
+ updated: number;
671
+ unread: number;
672
+ }>;
673
+ /** 账户级用量聚合(跨节点) */
674
+ interface HubUsageAgg {
675
+ calls: number;
676
+ input: number;
677
+ output: number;
678
+ cacheRead: number;
679
+ cacheWrite: number;
680
+ costUsd: number;
681
+ unpriced: number;
682
+ }
683
+ interface HubUsageView {
684
+ total: HubUsageAgg;
685
+ nodes: HubUsageNodeRow[];
686
+ days: {
687
+ key: string;
688
+ agg: HubUsageAgg;
689
+ }[];
690
+ /**
691
+ * 按项目拆分(同一项目在不同节点上分多条)。
692
+ * `projectName` 由 Hub 从节点项目快照补齐;旧版节点不上报项目维度时为空数组。
693
+ */
694
+ projects?: HubUsageProjectRow[];
695
+ from?: string;
696
+ to?: string;
697
+ }
698
+ /** 用量按节点拆分行 */
699
+ interface HubUsageNodeRow {
700
+ nodeId: string;
701
+ /** 节点展示名(Hub 节点记录里的 label;未命名时为 null,前端回退到 nodeId) */
702
+ nodeLabel?: string | null;
703
+ agg: HubUsageAgg;
704
+ updatedAt: string;
705
+ }
706
+ /** 用量按项目拆分行 */
707
+ interface HubUsageProjectRow {
708
+ nodeId: string;
709
+ /** 所属节点展示名(用于「项目已删除只剩 id」时定位) */
710
+ nodeLabel?: string | null;
711
+ projectId: string;
712
+ /** 项目展示名(节点快照里取;节点已删除或旧版节点为 null) */
713
+ projectName: string | null;
714
+ agg: HubUsageAgg;
715
+ }
716
+ declare function hubGetUsage(baseUrl: string, token: string, params?: {
717
+ from?: string;
718
+ to?: string;
719
+ groupBy?: "node" | "day";
720
+ }): Promise<HubUsageView>;
721
+ /** 节点上报用量(按天覆盖,幂等) */
722
+ declare function hubNodeUsageReport(baseUrl: string, token: string, nodeId: string, payload: {
723
+ total?: unknown;
724
+ byDay?: Record<string, unknown>;
725
+ /** 项目维度:projectId → { total, byDay } */
726
+ projects?: Record<string, unknown>;
727
+ since?: string;
728
+ }): Promise<void>;
729
+ type HubAdminRole = "user" | "admin";
730
+ type HubAdminUserStatus = "active" | "disabled" | "deleted";
731
+ /** 管理端用户行(列表与详情共用) */
732
+ interface HubAdminUserRow {
733
+ id: string;
734
+ email: string | null;
735
+ phone: string | null;
736
+ nickname: string | null;
737
+ plan: string;
738
+ planExpiresAt: string | null;
739
+ role: HubAdminRole;
740
+ status: HubAdminUserStatus;
741
+ disabledAt?: string | null;
742
+ deletedAt?: string | null;
743
+ createdAt: string;
744
+ passwordSet: boolean;
745
+ fleetCount: number;
746
+ nodeCount: number;
747
+ onlineCount: number;
748
+ subscription: {
749
+ plan: string;
750
+ period: string;
751
+ startedAt: string;
752
+ expiresAt: string;
753
+ channel: string;
754
+ amount: number;
755
+ } | null;
756
+ ordersCount: number;
757
+ paidCount: number;
758
+ paidCents: number;
759
+ /** 仅列表 ?withUsage=1 时返回 */
760
+ usage?: HubUsageAgg;
761
+ }
762
+ /** 管理端总览 */
763
+ interface HubAdminOverview {
764
+ users: {
765
+ total: number;
766
+ active: number;
767
+ disabled: number;
768
+ deleted: number;
769
+ admins: number;
770
+ newLast7d: number;
771
+ };
772
+ fleets: {
773
+ total: number;
774
+ };
775
+ nodes: {
776
+ total: number;
777
+ online: number;
778
+ };
779
+ orders: {
780
+ total: number;
781
+ paid: number;
782
+ created: number;
783
+ refunded: number;
784
+ revenueCents: number;
785
+ revenue30dCents: number;
786
+ byProvider: Array<{
787
+ provider: string;
788
+ count: number;
789
+ amount: number;
790
+ }>;
791
+ };
792
+ plans: {
793
+ free: number;
794
+ pro: number;
795
+ team: number;
796
+ };
797
+ usage: HubUsageAgg | null;
798
+ }
799
+ /** 管理端节点(含网关实时状态) */
800
+ interface HubAdminNode {
801
+ nodeId: string;
802
+ fleetId: string;
803
+ label?: string;
804
+ createdAt: string;
805
+ state: {
806
+ nodeId: string;
807
+ online: boolean;
808
+ lastSeen?: string;
809
+ platform?: string;
810
+ mode?: string;
811
+ version?: string;
812
+ ip?: string;
813
+ projects?: Array<{
814
+ id: string;
815
+ name: string;
816
+ sessionCount?: number;
817
+ running?: number;
818
+ waiting?: number;
819
+ }>;
820
+ totals?: HubNodeTotals | null;
821
+ stats?: FleetNodeStats | null;
822
+ };
823
+ }
824
+ /** 管理端订单行(含下单用户标识) */
825
+ interface HubAdminOrderRow {
826
+ id: string;
827
+ userId: string;
828
+ plan: string;
829
+ period: string;
830
+ amount: number;
831
+ currency: string;
832
+ provider: string;
833
+ status: string;
834
+ createdAt: string;
835
+ paidAt?: string;
836
+ providerTxnId?: string;
837
+ user: {
838
+ id: string;
839
+ email: string | null;
840
+ phone: string | null;
841
+ } | null;
842
+ }
843
+ /** 管理端用户详情 */
844
+ interface HubAdminUserDetail {
845
+ summary: HubAdminUserRow;
846
+ fleets: Array<{
847
+ id: string;
848
+ ownerId: string;
849
+ name: string;
850
+ ungrouped?: boolean;
851
+ nodeCount: number;
852
+ createdAt: string;
853
+ }>;
854
+ nodes: HubAdminNode[];
855
+ orders: HubAdminOrderRow[];
856
+ subscription: HubAdminUserRow["subscription"];
857
+ usage: HubUsageView | null;
858
+ }
859
+ interface HubAdminAuditEntry {
860
+ ts: string;
861
+ userId?: string;
862
+ action: string;
863
+ detail?: Record<string, unknown>;
864
+ }
865
+ /** 注册尝试记录(成功/失败都记;供管理后台监控注册问题) */
866
+ interface HubAdminRegisterAttempt {
867
+ id: string;
868
+ ts: string;
869
+ /** register=注册表单;auto_login=短信验证码登录时自动注册 */
870
+ source: "register" | "auto_login";
871
+ success: boolean;
872
+ email: string | null;
873
+ phone: string | null;
874
+ nickname: string | null;
875
+ /** 注册成功时为新用户 id */
876
+ userId: string | null;
877
+ /** 失败错误码(bad_request / email_exists / phone_exists / email_code_invalid…) */
878
+ errorCode: string | null;
879
+ errorMessage: string | null;
880
+ ip: string | null;
881
+ userAgent: string | null;
882
+ }
883
+ /** 总览统计 */
884
+ declare function hubAdminOverview(baseUrl: string, token: string): Promise<HubAdminOverview>;
885
+ /** 用户列表(q 匹配 id/邮箱/手机号) */
886
+ declare function hubAdminUsers(baseUrl: string, token: string, params?: {
887
+ q?: string;
888
+ status?: string;
889
+ role?: string;
890
+ plan?: string;
891
+ withUsage?: boolean;
892
+ limit?: number;
893
+ offset?: number;
894
+ }): Promise<{
895
+ total: number;
896
+ items: HubAdminUserRow[];
897
+ }>;
898
+ /** 用户详情(分组/节点/订单/订阅/用量) */
899
+ declare function hubAdminUserDetail(baseUrl: string, token: string, userId: string): Promise<HubAdminUserDetail>;
900
+ /** 修改套餐 / 有效期(planExpiresAt 传 null 清除) */
901
+ declare function hubAdminUpdateUser(baseUrl: string, token: string, userId: string, patch: {
902
+ plan?: string;
903
+ planExpiresAt?: string | null;
904
+ }): Promise<HubAdminUserRow>;
905
+ declare function hubAdminDisableUser(baseUrl: string, token: string, userId: string): Promise<{
906
+ id: string;
907
+ status: string;
908
+ }>;
909
+ declare function hubAdminEnableUser(baseUrl: string, token: string, userId: string): Promise<{
910
+ id: string;
911
+ status: string;
912
+ }>;
913
+ /** 软删用户(数据保留,可用 enable 恢复) */
914
+ declare function hubAdminDeleteUser(baseUrl: string, token: string, userId: string): Promise<{
915
+ id: string;
916
+ status: string;
917
+ }>;
918
+ /** 设置/取消管理员(服务端守卫最后一个管理员) */
919
+ declare function hubAdminSetRole(baseUrl: string, token: string, userId: string, role: HubAdminRole): Promise<{
920
+ id: string;
921
+ role: string;
922
+ }>;
923
+ /** 给用户发送站内通知 */
924
+ declare function hubAdminNotifyUser(baseUrl: string, token: string, userId: string, input: {
925
+ title: string;
926
+ body?: string;
927
+ link?: string;
928
+ }): Promise<{
929
+ sent: boolean;
930
+ notificationId: string | null;
931
+ }>;
932
+ /** 管理端删除分组(节点归入 owner 的「未分组」) */
933
+ declare function hubAdminDeleteFleet(baseUrl: string, token: string, fleetId: string): Promise<{
934
+ deleted: boolean;
935
+ movedNodes: number;
936
+ }>;
937
+ /** 管理端删除节点(仅移除 Hub 纳管记录) */
938
+ declare function hubAdminDeleteNode(baseUrl: string, token: string, nodeId: string): Promise<{
939
+ deleted: boolean;
940
+ }>;
941
+ /** 全站订单(可按状态/渠道/日期/关键词过滤) */
942
+ declare function hubAdminOrders(baseUrl: string, token: string, params?: {
943
+ status?: string;
944
+ provider?: string;
945
+ q?: string;
946
+ from?: string;
947
+ to?: string;
948
+ limit?: number;
949
+ offset?: number;
950
+ }): Promise<{
951
+ total: number;
952
+ items: HubAdminOrderRow[];
953
+ }>;
954
+ /** 订单手动标记:paid(激活套餐,幂等)/ refunded(仅状态+通知) */
955
+ declare function hubAdminMarkOrder(baseUrl: string, token: string, orderId: string, input: {
956
+ status: "paid" | "refunded";
957
+ note?: string;
958
+ }): Promise<HubAdminOrderRow>;
959
+ /** 审计日志(最新在前) */
960
+ declare function hubAdminAudit(baseUrl: string, token: string, params?: {
961
+ userId?: string;
962
+ action?: string;
963
+ limit?: number;
964
+ offset?: number;
965
+ }): Promise<{
966
+ total: number;
967
+ entries: HubAdminAuditEntry[];
968
+ }>;
969
+ /** 注册记录(最新在前;success 过滤结果,q 模糊匹配邮箱/手机号/昵称/IP) */
970
+ declare function hubAdminRegisterAttempts(baseUrl: string, token: string, params?: {
971
+ q?: string;
972
+ success?: boolean;
973
+ limit?: number;
974
+ offset?: number;
975
+ }): Promise<{
976
+ total: number;
977
+ entries: HubAdminRegisterAttempt[];
978
+ }>;
979
+ /**
980
+ * 账号级站内消息流(fetch 流式读取;EventSource 不能带 Authorization 头)。
981
+ *
982
+ * 「去 EMQX」后这是站内消息**唯一**的实时通道(从前是 MQTT 的账号通知 topic)。
983
+ * 断开期间由 `hubNotifications` 轮询兜底。
984
+ */
985
+ declare function hubNotificationStream(baseUrl: string, token: string, onNotification: (n: HubNotificationView) => void, onClosed?: () => void, onActivity?: () => void): () => void;
986
+ type HubNotifyChannelType = "email" | "sms" | "wechat" | "webhook";
987
+ type HubWebhookFormat = "generic" | "onebot" | "wecom" | "dingtalk" | "feishu";
988
+ interface HubNotifyChannelView {
989
+ id: string;
990
+ type: HubNotifyChannelType;
991
+ enabled: boolean;
992
+ /**
993
+ * email: `{ to, subjectPrefix? }`
994
+ * sms: `{ phone, includeLink? }`
995
+ * wechat: `{ openid, templateId?, fields?, url? }`
996
+ * webhook: `{ url, format, targetType?, target? }`
997
+ */
998
+ config: Record<string, string>;
999
+ }
1000
+ interface HubNotifySettingsView {
1001
+ enabled: boolean;
1002
+ events: {
1003
+ approval: boolean;
1004
+ question: boolean;
1005
+ completed: boolean;
1006
+ error: boolean;
1007
+ };
1008
+ channels: HubNotifyChannelView[];
1009
+ cooldownSeconds?: number;
1010
+ /** 聚合窗口(秒):窗口内事件合并成一封邮件;0 = 每条立即发送 */
1011
+ digestSeconds?: number;
1012
+ quietHours?: {
1013
+ start: string;
1014
+ end: string;
1015
+ };
1016
+ }
1017
+ interface HubNotifyChannelAvailability {
1018
+ email: boolean;
1019
+ sms: boolean;
1020
+ wechat: boolean;
1021
+ webhook: boolean;
1022
+ }
1023
+ interface HubNotifySettingsResponse {
1024
+ settings: HubNotifySettingsView;
1025
+ /** 当前套餐是否允许通知渠道(free 为 false) */
1026
+ planAllows: boolean;
1027
+ maxChannels: number;
1028
+ /** Hub 是否已启用告警订阅(缺网关地址/终端密钥时为 false) */
1029
+ alertsEnabled: boolean;
1030
+ /** 服务端各渠道后端是否就绪(未配置时发送必然失败) */
1031
+ available: HubNotifyChannelAvailability;
1032
+ }
1033
+ interface HubAlertEventView {
1034
+ id: string;
1035
+ userId: string;
1036
+ nodeId: string;
1037
+ nodeLabel?: string;
1038
+ fleetId: string;
1039
+ projectId?: string;
1040
+ sessionId: string;
1041
+ sessionName?: string | null;
1042
+ kind: "approval_request" | "question_asked" | "turn_completed" | "turn_stopped" | "error";
1043
+ title: string;
1044
+ body: string;
1045
+ link?: string;
1046
+ createdAt: string;
1047
+ }
1048
+ interface HubNotifyDeliveryResult {
1049
+ channelId: string;
1050
+ type: HubNotifyChannelType;
1051
+ ok: boolean;
1052
+ error?: string;
1053
+ }
1054
+ /** 读取当前账号的通知设置 */
1055
+ declare function hubNotifySettings(baseUrl: string, token: string): Promise<HubNotifySettingsResponse>;
1056
+ /** 保存通知设置(服务端校验;free 套餐返回 402) */
1057
+ declare function hubSaveNotifySettings(baseUrl: string, token: string, settings: HubNotifySettingsView): Promise<{
1058
+ settings: HubNotifySettingsView;
1059
+ }>;
1060
+ /**
1061
+ * 工作台置顶项(账号级,跨设备同步)。
1062
+ *
1063
+ * 键由「层级路径」拼成,用于在服务端排序前置顶项:
1064
+ * nodes `fleetId/nodeId`
1065
+ * projects `fleetId/nodeId/projectId`
1066
+ * tasks `fleetId/nodeId/projectId/sessionId`
1067
+ *
1068
+ * 存用户实体(PG 是 `hub_users.data` jsonb),新增不需要迁移。
1069
+ */
1070
+ interface HubPins {
1071
+ nodes: string[];
1072
+ projects: string[];
1073
+ tasks: string[];
1074
+ }
1075
+ /** 读取当前账号的置顶项 */
1076
+ declare function hubPins(baseUrl: string, token: string): Promise<HubPins>;
1077
+ /** 整体保存置顶项(前端本地已是全量,切换一次就回写一次) */
1078
+ declare function hubSavePins(baseUrl: string, token: string, pins: HubPins): Promise<{
1079
+ pins: HubPins;
1080
+ }>;
1081
+ /** 向所有启用渠道发送一条测试通知 */
1082
+ declare function hubTestNotify(baseUrl: string, token: string): Promise<{
1083
+ alert: HubAlertEventView;
1084
+ results: HubNotifyDeliveryResult[];
1085
+ }>;
1086
+ /** 最近的任务告警(内存记录,用于设置页/排查) */
1087
+ declare function hubNotifyEvents(baseUrl: string, token: string, limit?: number): Promise<{
1088
+ items: HubAlertEventView[];
1089
+ }>;
1090
+ interface HubSmtpView {
1091
+ host: string;
1092
+ port: number;
1093
+ secure: boolean;
1094
+ user?: string;
1095
+ from?: string;
1096
+ /** 是否已保存授权码(接口永不回传明文) */
1097
+ hasPass: boolean;
1098
+ }
1099
+ interface HubSmtpResponse {
1100
+ smtp: HubSmtpView | null;
1101
+ /** 服务端是否配置了 HUB_SMTP_*(未配账号级时用它发) */
1102
+ serverConfigured: boolean;
1103
+ /** 是否允许在 Portal 里配置(服务端启用了加密存储) */
1104
+ editable: boolean;
1105
+ }
1106
+ /** 读取账号级发件配置(脱敏) */
1107
+ declare function hubSmtpSettings(baseUrl: string, token: string): Promise<HubSmtpResponse>;
1108
+ /**
1109
+ * 保存账号级发件配置。
1110
+ *
1111
+ * `pass` 省略表示保留原授权码;传空串表示清空(内网无认证 SMTP)。
1112
+ */
1113
+ declare function hubSaveSmtpSettings(baseUrl: string, token: string, input: {
1114
+ host: string;
1115
+ port: number;
1116
+ secure: boolean;
1117
+ user?: string;
1118
+ pass?: string;
1119
+ from?: string;
1120
+ }): Promise<{
1121
+ smtp: HubSmtpView;
1122
+ }>;
1123
+ /** 清除账号级发件配置(回落到服务端 HUB_SMTP_*) */
1124
+ declare function hubClearSmtpSettings(baseUrl: string, token: string): Promise<HubSmtpResponse>;
1125
+ /** 示例邮件预览(服务端用该账号真实节点快照渲染) */
1126
+ declare function hubNotifyPreview(baseUrl: string, token: string): Promise<{
1127
+ subject: string;
1128
+ text: string;
1129
+ html: string;
1130
+ nodeCount: number;
1131
+ }>;
1132
+ /** 节点按天计费配置 */
1133
+ interface HubNodeBillingConfigView {
1134
+ currency: "CNY";
1135
+ /** 免费可管理的节点数;0 = 没有免费额度 */
1136
+ freeNodes: number;
1137
+ /** 每个计费节点每天的价格(分) */
1138
+ dailyPriceCents: number;
1139
+ /** 余额可维持天数的预警阈值(天),降序 */
1140
+ warnDays: number[];
1141
+ }
1142
+ interface HubNodeBillingConfigResponse {
1143
+ pricing: HubNodeBillingConfigView;
1144
+ isDefault: boolean;
1145
+ examples: Array<{
1146
+ /** 节点总台数(含免费额度) */
1147
+ totalNodes: number;
1148
+ billableNodes: number;
1149
+ dailyYuan: number;
1150
+ monthlyYuan: number;
1151
+ }>;
1152
+ }
1153
+ /** 官网用户群二维码(管理后台上传,官网运行时按固定 URL 拉取) */
1154
+ interface HubCommunityQrView {
1155
+ /** `data:image/png;base64,...` */
1156
+ dataUrl: string;
1157
+ updatedAt: string;
1158
+ }
1159
+ interface HubCommunityQrResponse {
1160
+ qr: HubCommunityQrView | null;
1161
+ }
1162
+ /** 官网二维码列表项(管理后台;含图片数据,供预览) */
1163
+ interface HubSocialQrItem {
1164
+ /** 稳定标识,站点用它拼图片地址 `/api/hub/community/qrs/<id>` */
1165
+ id: string;
1166
+ /** 展示名称,如「企业微信群」「公众号」「抖音」 */
1167
+ name: string;
1168
+ /** `data:image/png;base64,...` */
1169
+ dataUrl: string;
1170
+ updatedAt: string;
1171
+ /** 是否在官网展示;下线只是隐藏,图片仍保留 */
1172
+ online: boolean;
1173
+ }
1174
+ interface HubSocialQrsResponse {
1175
+ items: HubSocialQrItem[];
1176
+ }
1177
+ interface HubZqaiApiRequest {
1178
+ at: string;
1179
+ purpose: string;
1180
+ monthlyVolume?: string;
1181
+ contact?: string;
1182
+ status: "pending" | "approved" | "rejected";
1183
+ }
1184
+ interface HubZqaiBalance {
1185
+ currency: string;
1186
+ available: number;
1187
+ available_micros: number;
1188
+ reserved: number;
1189
+ ledger_balance: number | null;
1190
+ source: string;
1191
+ as_of: string;
1192
+ }
1193
+ interface HubZqaiUsageSummary {
1194
+ requests: number;
1195
+ prompt_tokens: number;
1196
+ cached_tokens: number;
1197
+ completion_tokens: number;
1198
+ reasoning_tokens: number;
1199
+ charge: number;
1200
+ charge_micros: number;
1201
+ failed_requests: number;
1202
+ }
1203
+ interface HubZqaiUsageBucket extends HubZqaiUsageSummary {
1204
+ day?: string;
1205
+ model?: string;
1206
+ }
1207
+ interface HubZqaiUsage {
1208
+ from: string;
1209
+ to: string;
1210
+ group_by: string;
1211
+ summary: HubZqaiUsageSummary;
1212
+ items: HubZqaiUsageBucket[];
1213
+ }
1214
+ interface HubZqaiRecharge {
1215
+ id: number;
1216
+ created_at: string;
1217
+ amount: number;
1218
+ amount_micros: number;
1219
+ balance_after: number;
1220
+ note: string | null;
1221
+ /**
1222
+ * 支付渠道(wechat / alipay / zqpay)。engine 流水本身不带渠道,
1223
+ * hub 按 note 里的订单号回查本地订单补出来;运营调账 / 注册赠送为 null。
1224
+ */
1225
+ provider?: string | null;
1226
+ /**
1227
+ * 聚合收单(provider = zqpay)下用户实际选的支付方式(wechat / alipay)。
1228
+ * 直连渠道或回查不到订单时为 null —— 前端只显示 provider。
1229
+ */
1230
+ channel?: string | null;
1231
+ }
1232
+ interface HubZqaiRecharges {
1233
+ count: number;
1234
+ total: number;
1235
+ total_micros: number;
1236
+ items: HubZqaiRecharge[];
1237
+ }
1238
+ interface HubApiServiceView {
1239
+ linked: boolean;
1240
+ tenantId: number | null;
1241
+ gatewayConfigured: boolean;
1242
+ request: HubZqaiApiRequest | null;
1243
+ balance: HubZqaiBalance | null;
1244
+ usage: HubZqaiUsage | null;
1245
+ recharges: HubZqaiRecharges | null;
1246
+ /** 节点计费概览(没有套餐上限,只有「可用 / 计费 / 免费」三个数) */
1247
+ nodes: {
1248
+ total: number;
1249
+ /** 可用总数(含免费额度) */
1250
+ activeTotal: number;
1251
+ freeNodes: number;
1252
+ billable: number;
1253
+ active: number;
1254
+ };
1255
+ /** 明文 Key(仅返回给本人;页面上默认打码) */
1256
+ apiKey?: string | null;
1257
+ /** 打码后的 Key,可安全地展示在截图里 */
1258
+ apiKeyMasked?: string | null;
1259
+ /** 调用地址,页面拼示例代码用 */
1260
+ apiBaseUrl?: string;
1261
+ /** 自动开通是否启用(关闭时走「提交申请」的老流程) */
1262
+ provisionEnabled?: boolean;
1263
+ /** 最近一次自动开通失败的原因 */
1264
+ provisionError?: string | null;
1265
+ /** 累计获得的注册赠金(元) */
1266
+ bonusYuan?: number;
1267
+ }
1268
+ declare function hubApiService(baseUrl: string, token: string, opts?: {
1269
+ from?: string;
1270
+ to?: string;
1271
+ groupBy?: "day" | "model";
1272
+ }): Promise<HubApiServiceView>;
1273
+ /**
1274
+ * 重置 API Key:旧 Key 立即失效。
1275
+ *
1276
+ * 注意:engine 每 5 秒轮询配置,**新 Key 生效、旧 Key 失效都有约 5 秒延迟**。
1277
+ * 页面上的提示要说明这一点,否则用户重置后立刻测试会看到旧 Key 仍可用。
1278
+ */
1279
+ declare function hubRotateApiKey(baseUrl: string, token: string): Promise<{
1280
+ apiKey: string;
1281
+ apiKeyMasked: string;
1282
+ tenantId: number;
1283
+ }>;
1284
+ declare function hubRequestApiService(baseUrl: string, token: string, input: {
1285
+ purpose: string;
1286
+ monthlyVolume?: string;
1287
+ contact?: string;
1288
+ }): Promise<{
1289
+ submitted: boolean;
1290
+ request: HubZqaiApiRequest;
1291
+ }>;
1292
+ declare function hubAdminNodeBilling(baseUrl: string, token: string): Promise<HubNodeBillingConfigResponse>;
1293
+ declare function hubAdminUpdateNodeBilling(baseUrl: string, token: string, pricing: HubNodeBillingConfigView): Promise<{
1294
+ pricing: HubNodeBillingConfigView;
1295
+ }>;
1296
+ /** 充值来源:user=本人自助充值 / admin=运营代充 / bonus=注册赠金 / other=历史数据 */
1297
+ type HubAdminRechargeSource = "user" | "admin" | "bonus" | "other";
1298
+ /** 管理后台看单个用户的账户:余额 + 消费列表 + 充值列表 */
1299
+ interface HubAdminWalletView {
1300
+ userId: string;
1301
+ /** 余额(分);null = 暂时读不到,不等于 0 */
1302
+ balanceCents: number | null;
1303
+ /** 已预留未结算(分) */
1304
+ reservedCents: number | null;
1305
+ currency: string;
1306
+ /** 是否已接入 engine 且该用户已开户;false 时余额/流水全为 null */
1307
+ linked: boolean;
1308
+ tenantId: number | null;
1309
+ /**
1310
+ * 消费列表。
1311
+ *
1312
+ * engine 只提供按天 / 按模型的聚合(没有逐条调用流水),所以这里是汇总行,
1313
+ * `groupBy` 决定 `day` 有值还是 `model` 有值。
1314
+ */
1315
+ usage: {
1316
+ groupBy: "day" | "model";
1317
+ from: string;
1318
+ to: string;
1319
+ summary: {
1320
+ requests: number;
1321
+ promptTokens: number;
1322
+ completionTokens: number;
1323
+ chargeCents: number;
1324
+ failedRequests: number;
1325
+ };
1326
+ items: Array<{
1327
+ day: string | null;
1328
+ model: string | null;
1329
+ requests: number;
1330
+ promptTokens: number;
1331
+ completionTokens: number;
1332
+ chargeCents: number;
1333
+ }>;
1334
+ } | null;
1335
+ /** 充值列表(engine 流水),带来源标记 */
1336
+ entries: Array<{
1337
+ id: string;
1338
+ deltaCents: number;
1339
+ balanceAfterCents: number;
1340
+ ref: string;
1341
+ /** 去掉机器标记后的说明 */
1342
+ note?: string;
1343
+ source: HubAdminRechargeSource;
1344
+ /** 仅 source=admin 时有值 */
1345
+ adminName: string | null;
1346
+ /** 支付渠道(本人自助充值时由订单回查) */
1347
+ provider: string | null;
1348
+ createdAt: string;
1349
+ }>;
1350
+ }
1351
+ /** 管理后台查看某个用户的余额、消费与充值记录 */
1352
+ declare function hubAdminWallet(baseUrl: string, token: string, userId: string, opts?: {
1353
+ from?: string;
1354
+ to?: string;
1355
+ groupBy?: "day" | "model";
1356
+ }): Promise<HubAdminWalletView>;
1357
+ /**
1358
+ * 运营代充:直接给目标用户的账户余额入账。
1359
+ *
1360
+ * 记录会带来源标记(`运营代充 · <说明> · adm:<ref>`),管理后台与用户侧的
1361
+ * 充值列表都能看出这一笔是运营代为充值的。
1362
+ */
1363
+ declare function hubAdminTopup(baseUrl: string, token: string, userId: string, input: {
1364
+ amountYuan: number;
1365
+ note?: string;
1366
+ }): Promise<{
1367
+ userId: string;
1368
+ balanceCents: number;
1369
+ }>;
1370
+ /** 读取官网用户群二维码(管理后台) */
1371
+ declare function hubAdminCommunity(baseUrl: string, token: string): Promise<HubCommunityQrResponse>;
1372
+ /** 保存官网用户群二维码;dataUrl 形如 `data:image/png;base64,...` */
1373
+ declare function hubAdminUpdateCommunity(baseUrl: string, token: string, dataUrl: string): Promise<HubCommunityQrResponse>;
1374
+ /** 清除官网用户群二维码(官网回退到内置占位图) */
1375
+ declare function hubAdminClearCommunity(baseUrl: string, token: string): Promise<HubCommunityQrResponse>;
1376
+ /** 官网二维码列表(全部项,含未上线;后台预览用) */
1377
+ declare function hubAdminSocialQrs(baseUrl: string, token: string): Promise<HubSocialQrsResponse>;
1378
+ /** 新增一个二维码(名称 + 图片 data URL) */
1379
+ declare function hubAdminAddSocialQr(baseUrl: string, token: string, input: {
1380
+ id?: string;
1381
+ name: string;
1382
+ dataUrl: string;
1383
+ online?: boolean;
1384
+ }): Promise<{
1385
+ item: HubSocialQrItem;
1386
+ }>;
1387
+ /** 局部更新:改名 / 换图 / 上线下线,只传需要改的字段 */
1388
+ declare function hubAdminUpdateSocialQr(baseUrl: string, token: string, id: string, patch: {
1389
+ name?: string;
1390
+ dataUrl?: string;
1391
+ online?: boolean;
1392
+ }): Promise<{
1393
+ item: HubSocialQrItem;
1394
+ }>;
1395
+ /** 删除一个二维码 */
1396
+ declare function hubAdminRemoveSocialQr(baseUrl: string, token: string, id: string): Promise<{
1397
+ ok: boolean;
1398
+ }>;
1399
+ /** 绑定 zqai 租户,或驳回申请(reject: true) */
1400
+ declare function hubAdminLinkZqai(baseUrl: string, token: string, userId: string, input: {
1401
+ tenantId?: number;
1402
+ reject?: boolean;
1403
+ }): Promise<Record<string, unknown>>;
1404
+ interface HubWalletEntryView {
1405
+ id: string;
1406
+ userId: string;
1407
+ deltaCents: number;
1408
+ balanceAfterCents: number;
1409
+ ref: string;
1410
+ note?: string;
1411
+ createdAt: string;
1412
+ /** 支付渠道(wechat / alipay);非下单充值(调账 / 赠送)为 null */
1413
+ provider?: string | null;
1414
+ }
1415
+ /** 节点计费概览:可用台数由余额决定 */
1416
+ interface HubNodeBillingView {
1417
+ freeNodes: number;
1418
+ /** 每个计费节点每天的价格(分) */
1419
+ dailyPriceCents: number;
1420
+ /** 节点总台数(含免费额度) */
1421
+ totalNodes: number;
1422
+ /** 当前可用节点总数(含免费额度那几台) */
1423
+ activeTotalNodes: number;
1424
+ /** 计费节点数 = max(0, totalNodes - freeNodes) */
1425
+ billableNodes: number;
1426
+ /** 当前可用的计费节点数 */
1427
+ activeNodes: number;
1428
+ /** 因余额不足被暂停的计费节点数 */
1429
+ suspendedNodes: number;
1430
+ status: "active" | "suspended";
1431
+ /** 已结算到哪一天 */
1432
+ billedThrough: string | null;
1433
+ /** true = 不参与按天计费(admin 账号 / license 实例),UI 应隐藏余额预警 */
1434
+ exempt: boolean;
1435
+ /** 余额还能撑几天;无计费可用节点时为 null */
1436
+ daysRemaining: number | null;
1437
+ /** 预警阈值,降序(如 [15,7,3]) */
1438
+ warnDays: number[];
1439
+ /** 命中的预警档位;未命中为 null */
1440
+ warningTier: number | null;
1441
+ }
1442
+ /**
1443
+ * 账户余额 + 节点计费概览。
1444
+ *
1445
+ * 余额只有一份(zqai 租户账本):API 调用与节点计费都从它扣,
1446
+ * 充值也只有一条链路。`balanceCents` 为 null 表示暂时读不到(engine 未接入/抖动),
1447
+ * 而不是「余额为 0」。
1448
+ */
1449
+ interface HubWalletView {
1450
+ balanceCents: number | null;
1451
+ /** 充值记录(来自 engine 的流水) */
1452
+ entries: HubWalletEntryView[];
1453
+ nodeBilling: HubNodeBillingView;
1454
+ }
1455
+ declare function hubWallet(baseUrl: string, token: string): Promise<HubWalletView>;
1456
+ declare function hubWalletTopup(baseUrl: string, token: string, input: {
1457
+ amountYuan: number;
1458
+ provider?: string;
1459
+ }): Promise<{
1460
+ order: {
1461
+ id: string;
1462
+ amount: number;
1463
+ status: string;
1464
+ };
1465
+ mode: string;
1466
+ qrContent: string | null;
1467
+ redirectUrl: string | null;
1468
+ }>;
1469
+ declare function hubApiTopup(baseUrl: string, token: string, input: {
1470
+ amountYuan: number;
1471
+ provider?: string;
1472
+ channel?: "wechat" | "alipay" | "any";
1473
+ }): Promise<{
1474
+ order: {
1475
+ id: string;
1476
+ amount: number;
1477
+ status: string;
1478
+ };
1479
+ mode: string;
1480
+ qrContent: string | null;
1481
+ redirectUrl: string | null;
1482
+ }>;
1483
+ interface HubBillingReport {
1484
+ object: string;
1485
+ currency: string;
1486
+ from: string;
1487
+ to: string;
1488
+ wallet: {
1489
+ topupCents: number;
1490
+ /** 运营代充入账(来自审计;这笔钱不走支付渠道) */
1491
+ adminTopupCents: number;
1492
+ refundCents: number;
1493
+ /** 席位按天扣费合计 */
1494
+ seatCents: number;
1495
+ adjustCents: number;
1496
+ netCents: number;
1497
+ entries: number;
1498
+ /** 余额在 engine 侧,hub 不再持有快照;null 表示需要到 engine 查 */
1499
+ closingBalanceCents: number | null;
1500
+ };
1501
+ orders: {
1502
+ walletTopup: {
1503
+ count: number;
1504
+ cents: number;
1505
+ };
1506
+ apiTopup: {
1507
+ count: number;
1508
+ cents: number;
1509
+ };
1510
+ plan: {
1511
+ count: number;
1512
+ cents: number;
1513
+ };
1514
+ refundedCount: number;
1515
+ refundedCents: number;
1516
+ };
1517
+ nodeBilling: {
1518
+ /** 有计费节点的用户数 */
1519
+ billedUsers: number;
1520
+ /** 有节点因余额被暂停的用户数 */
1521
+ suspendedUsers: number;
1522
+ activeBillableNodes: number;
1523
+ dailyPriceCents: number;
1524
+ freeNodes: number;
1525
+ /** 按「可用计费节点 × 日单价 × 30」估算 */
1526
+ mrrCents: number;
1527
+ };
1528
+ users: {
1529
+ total: number;
1530
+ paidInRange: number;
1531
+ };
1532
+ /** 按天序列:区间内每天一条(无数据的天补 0),用于趋势与逐日对账 */
1533
+ series: HubBillingDayPoint[];
1534
+ /** 运营代充:明细 + 汇总 */
1535
+ adminTopups: {
1536
+ count: number;
1537
+ cents: number;
1538
+ items: HubAdminTopupRow[];
1539
+ };
1540
+ /** 订单明细(新 → 旧) */
1541
+ orderItems: HubBillingOrderRow[];
1542
+ }
1543
+ /** 报表里的一天 */
1544
+ interface HubBillingDayPoint {
1545
+ /** YYYY-MM-DD(UTC,与审计/账本口径一致) */
1546
+ day: string;
1547
+ /** 用户自助充值 */
1548
+ topupCents: number;
1549
+ /** 运营代充 */
1550
+ adminTopupCents: number;
1551
+ /** 退款 */
1552
+ refundCents: number;
1553
+ /** 席位扣费 */
1554
+ seatCents: number;
1555
+ /** 套餐收入 */
1556
+ planCents: number;
1557
+ orderCount: number;
1558
+ /** 净流入 = 充值 + 代充 + 套餐 − 退款 */
1559
+ netCents: number;
1560
+ }
1561
+ /** 一笔运营代充 */
1562
+ interface HubAdminTopupRow {
1563
+ ts: string;
1564
+ adminId: string;
1565
+ adminName: string | null;
1566
+ targetUserId: string;
1567
+ targetName: string | null;
1568
+ deltaCents: number;
1569
+ reason: string | null;
1570
+ ref: string | null;
1571
+ }
1572
+ /** 一条订单明细 */
1573
+ interface HubBillingOrderRow {
1574
+ id: string;
1575
+ createdAt: string;
1576
+ paidAt: string | null;
1577
+ userId: string;
1578
+ userName: string | null;
1579
+ purpose: "plan" | "wallet" | "api_topup";
1580
+ plan: string;
1581
+ period: string;
1582
+ amountCents: number;
1583
+ provider: string;
1584
+ status: string;
1585
+ }
1586
+ declare function hubAdminBillingReport(baseUrl: string, token: string, range?: {
1587
+ from?: string;
1588
+ to?: string;
1589
+ }): Promise<HubBillingReport>;
1590
+ /** 报表 CSV 下载地址(前端直接用带 token 的 fetch 拉,或拼到 a[href])。 */
1591
+ declare function hubBillingExportUrl(baseUrl: string, range?: {
1592
+ from?: string;
1593
+ to?: string;
1594
+ }): string;
1595
+ declare function hubAdminRefund(baseUrl: string, token: string, userId: string, input: {
1596
+ amountYuan: number;
1597
+ reason: string;
1598
+ orderId?: string;
1599
+ }): Promise<{
1600
+ userId: string;
1601
+ orderId: string | null;
1602
+ amountCents: number;
1603
+ balanceCents?: number;
1604
+ }>;
1605
+ interface HubStatement {
1606
+ object: string;
1607
+ currency: string;
1608
+ from: string;
1609
+ to: string;
1610
+ user: {
1611
+ id: string;
1612
+ email: string | null;
1613
+ phone: string | null;
1614
+ };
1615
+ nodeBilling: {
1616
+ freeNodes: number;
1617
+ dailyPriceCents: number;
1618
+ billableNodes: number;
1619
+ status: string;
1620
+ billedThrough: string | null;
1621
+ };
1622
+ totals: {
1623
+ walletTopupCents: number;
1624
+ nodeChargeCents: number;
1625
+ /** 模型调用扣费(engine 按 token 自动扣) */
1626
+ modelChargeCents: number;
1627
+ /** 总支出 = 节点 + 模型 */
1628
+ spendCents: number;
1629
+ refundCents: number;
1630
+ adjustCents: number;
1631
+ /** engine 不可达时为 null(不要当成 0) */
1632
+ closingBalanceCents: number | null;
1633
+ balanceSource: string | null;
1634
+ };
1635
+ nodeCharges: Array<{
1636
+ at: string;
1637
+ /** 计费自然日(东八区) */
1638
+ day: string;
1639
+ amountCents: number;
1640
+ /** 计费节点总数 */
1641
+ billableNodes: number;
1642
+ /** 当天实际可用(付得起)的计费节点数 */
1643
+ activeNodes: number;
1644
+ dailyPriceCents: number;
1645
+ }>;
1646
+ entries: Array<{
1647
+ at: string;
1648
+ ref: string;
1649
+ amountCents: number;
1650
+ balanceAfterCents: number | null;
1651
+ note: string | null;
1652
+ channel: "engine" | "order";
1653
+ /** 支付渠道(wechat / alipay);非下单充值(调账 / 赠送)为 null */
1654
+ provider?: string | null;
1655
+ }>;
1656
+ modelUsage: {
1657
+ summary: Record<string, number | string>;
1658
+ items: Array<Record<string, unknown>>;
1659
+ } | null;
1660
+ orders: Array<{
1661
+ id: string;
1662
+ at: string;
1663
+ purpose: string;
1664
+ plan: string;
1665
+ period: string;
1666
+ amountCents: number;
1667
+ status: string;
1668
+ provider: string;
1669
+ paidAt: string | null;
1670
+ }>;
1671
+ }
1672
+ declare function hubStatement(baseUrl: string, token: string, range?: {
1673
+ from?: string;
1674
+ to?: string;
1675
+ }): Promise<HubStatement>;
1676
+
1677
+ export { type HubAdminAuditEntry, type HubAdminNode, type HubAdminOrderRow, type HubAdminOverview, type HubAdminRechargeSource, type HubAdminRegisterAttempt, type HubAdminRole, type HubAdminTopupRow, type HubAdminUserDetail, type HubAdminUserRow, type HubAdminUserStatus, type HubAdminWalletView, type HubAlertEventView, type HubApiServiceView, type HubAuthInput, type HubBillingDayPoint, type HubBillingOrderRow, type HubBillingReport, type HubCaptchaView, type HubCommunityQrResponse, type HubCommunityQrView, type HubEnrollmentView, type HubFleetSummary, type HubGatewayCredentialView, type HubGatewayFleet, type HubNodeAccessView, type HubNodeActivityItem, type HubNodeBillingConfigResponse, type HubNodeBillingConfigView, type HubNodeBillingView, type HubNodeDetail, type HubNodeGrantView, type HubNodeSummary, type HubNodeTotals, type HubNotificationView, type HubNotifyChannelAvailability, type HubNotifyChannelType, type HubNotifyChannelView, type HubNotifyDeliveryResult, type HubNotifySettingsResponse, type HubNotifySettingsView, type HubOrderView, type HubOutgoingGrant, type HubPairingView, type HubPins, type HubPlan, type HubProjectPage, type HubProjectRow, type HubProjectTask, type HubSendCodeStatus, type HubSharedNode, type HubSmsPurpose, type HubSmtpResponse, type HubSmtpView, type HubSocialQrItem, type HubSocialQrsResponse, type HubStatement, type HubSubscriptionView, type HubTaskCounts, type HubTaskPage, type HubTaskRow, type HubTerminalCredential, type HubUsageAgg, type HubUsageNodeRow, type HubUsageProjectRow, type HubUsageView, type HubUserView, type HubWalletEntryView, type HubWalletView, type HubWebhookFormat, type HubZqaiApiRequest, type HubZqaiBalance, type HubZqaiRecharge, type HubZqaiRecharges, type HubZqaiUsage, type HubZqaiUsageBucket, type HubZqaiUsageSummary, activityKey, compareByActivity, hubAdminAddSocialQr, hubAdminAudit, hubAdminBillingReport, hubAdminClearCommunity, hubAdminCommunity, hubAdminDeleteFleet, hubAdminDeleteNode, hubAdminDeleteUser, hubAdminDisableUser, hubAdminEnableUser, hubAdminLinkZqai, hubAdminMarkOrder, hubAdminNodeBilling, hubAdminNotifyUser, hubAdminOrders, hubAdminOverview, hubAdminRefund, hubAdminRegisterAttempts, hubAdminRemoveSocialQr, hubAdminSetRole, hubAdminSocialQrs, hubAdminTopup, hubAdminUpdateCommunity, hubAdminUpdateNodeBilling, hubAdminUpdateSocialQr, hubAdminUpdateUser, hubAdminUserDetail, hubAdminUsers, hubAdminWallet, hubApiService, hubApiTopup, hubBillingExportUrl, hubCaptcha, hubChangePassword, hubChannels, hubClearSmtpSettings, hubCreateEnrollment, hubCreateFleet, hubCreateNodeGrant, hubDeleteFleet, hubDeleteNode, hubEnrollByAccount, hubEnrollByCode, hubEnrollByToken, hubEnrollNode, hubFleetPairing, hubGetNode, hubGetNodeById, hubGetUsage, hubLeaveSharedNode, hubListFleets, hubListNodeGrants, hubListNodes, hubListProjects, hubListTasks, hubLogin, hubLoginAccount, hubMarkNotificationsRead, hubMe, hubMoveNode, hubNodeActivity, hubNodeUsageReport, hubNotificationStream, hubNotifications, hubNotifyEvents, hubNotifyPreview, hubNotifySettings, hubOrders, hubOutgoingGrants, hubPins, hubPlans, hubRealtimeCredential, hubRegister, hubRegisterAccount, hubRequestApiService, hubResetPassword, hubRevokeNodeGrant, hubRotateApiKey, hubSaveNotifySettings, hubSavePins, hubSaveSmtpSettings, hubSendCodeStatus, hubSendEmailCode, hubSendSms, hubSharedNodes, hubSmsStatus, hubSmtpSettings, hubStatement, hubSubscription, hubSyncOrder, hubTerminalCredential, hubTestNotify, hubUpdateFleet, hubUpdateNode, hubUpdateNodeLabelSelf, hubUpdateProfile, hubWallet, hubWalletTopup, setHubBaseResolver };