hob-bot 1.3.0 → 1.4.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.
package/shared/types.ts CHANGED
@@ -227,7 +227,7 @@ export interface Assistant {
227
227
  pinned: boolean; // 左栏顶部大头像
228
228
  hidden: boolean; // 收起的助手
229
229
  notify: boolean; // 需要确认时通知我
230
- instructions: string; // 补充说明:用户可直接编辑的自定义指令,这个助手特有的做法写这里
230
+ instructions: string; // 补充说明:用户可直接编辑该助手需要知道的专属事实
231
231
  /** 这个助手用哪些模型;缺省全部跟随设置 → 模型 */
232
232
  models?: {
233
233
  conversation?: ModelPick; // 不填 = 跟随全局的对话模型
@@ -368,6 +368,12 @@ export interface JobsPage {
368
368
  hasMore: boolean;
369
369
  }
370
370
 
371
+ export type SedimentStatus =
372
+ | { status: "running" }
373
+ | { status: "saved"; name: string; title: string; version: number; updated: boolean }
374
+ | { status: "empty"; reason: string }
375
+ | { status: "failed"; reason: string };
376
+
371
377
  export interface Job {
372
378
  id: string; // "t-" + 4 位以上
373
379
  assistantId: string;
@@ -392,6 +398,8 @@ export interface Job {
392
398
  modelReason?: string; // 换了模型的原因,如「需要看图,换成了 X」
393
399
  inputs?: string[]; // 交给任务的附件(绝对路径)
394
400
  routineId?: string; // 由定时触发
401
+ sediment?: SedimentStatus; // 在原任务中沉淀技能,不改变任务状态
402
+ skills?: string[]; // 派活时交给任务的本助手技能
395
403
  skillsUsed?: string[]; // 这次读过的本助手技能(AssistantSkill.name)
396
404
  delegationId?: string; // 转交回合创建的任务
397
405
  /** 续做前每一轮结束时的样子(第 0 轮起)。对话里前面几张任务卡照它显示,最后一张跟着任务实时变 */
@@ -549,6 +557,78 @@ export interface PushSettings {
549
557
  email: string;
550
558
  }
551
559
 
560
+ /** 每百万 token 的单价(美元),四项。 */
561
+ export interface TokenPrice {
562
+ input: number;
563
+ output: number;
564
+ cacheRead: number;
565
+ cacheWrite: number;
566
+ }
567
+
568
+ /** 设置 → 消耗:按模型改过的单价,键是模型 id(服务商 id 是用户自己起的,价格按模型 id 对)。 */
569
+ export interface UsageSettings {
570
+ prices: Record<string, TokenPrice>;
571
+ }
572
+
573
+ /** 用量的来源:助手自己的对话 / 任务的会话。 */
574
+ export type UsageSource = "chat" | "job";
575
+
576
+ /** GET /api/usage 的一行:按天 × 助手 × 来源 × 服务商 × 模型汇总;day 是设置时区下的日期。 */
577
+ export interface UsageRow {
578
+ day: string; // 2026-11-06
579
+ assistantId: string;
580
+ source: UsageSource;
581
+ provider: string;
582
+ model: string;
583
+ requests: number; // assistant 消息条数
584
+ input: number; // 没命中缓存的输入 token
585
+ output: number;
586
+ cacheRead: number;
587
+ cacheWrite: number;
588
+ }
589
+
590
+ /** 有会话文件的助手(归档的也算),「按助手」一节用它的名字。 */
591
+ export interface UsageAssistant {
592
+ id: string;
593
+ name: string;
594
+ archived: boolean;
595
+ }
596
+
597
+ /** 一个模型现在的单价:改过的是自定,default 是价格表里的默认值(恢复默认和对比用)。 */
598
+ export interface UsageModelPrice {
599
+ price: TokenPrice;
600
+ custom: boolean;
601
+ default?: TokenPrice;
602
+ }
603
+
604
+ /** 价格表:默认单价从 models.dev 拉,一天最多更新一次。 */
605
+ export interface UsagePrices {
606
+ updatedAt: Iso | null; // 价格表拉到的时间;从没拉到过为 null
607
+ error: string | null; // 这次更新价格表失败的原因;成功为 null
608
+ models: Record<string, UsageModelPrice>; // 键是模型 id
609
+ }
610
+
611
+ /** GET /api/usage:按天、助手、来源、服务商、模型分组的明细 + 价格;前端自己汇总。 */
612
+ export interface UsageView {
613
+ timezone: string;
614
+ rows: UsageRow[];
615
+ assistants: UsageAssistant[];
616
+ prices: UsagePrices;
617
+ }
618
+
619
+ /** PUT /api/usage/price:改一个模型的单价,price 为 null 就恢复默认。 */
620
+ export interface UsagePricePatch {
621
+ revision: number;
622
+ model: string;
623
+ price: TokenPrice | null;
624
+ }
625
+
626
+ /** PUT /api/usage/price:新 revision 的整份设置 + 这个模型现在的单价(既没价格表也没自定时为 null)。 */
627
+ export interface UsagePriceSaved {
628
+ settings: SettingsFile;
629
+ price: UsageModelPrice | null;
630
+ }
631
+
552
632
  export interface Settings {
553
633
  general: GeneralSettings;
554
634
  /** 服务商(Key 在 secrets.json,这里只放不敏感的) */
@@ -565,6 +645,8 @@ export interface Settings {
565
645
  push: PushSettings;
566
646
  /** 知识库二期:向量模型(Key 在 secrets.json 的 embedding);缺省 = 关闭,只按关键词查 */
567
647
  knowledge?: { embedding: EmbeddingSettings };
648
+ /** 消耗:按模型改过的单价;没改过的模型用 models.dev 的价格 */
649
+ usage?: UsageSettings;
568
650
  }
569
651
 
570
652
  /** 设置 → 知识库:向量模型,照图像生成的做法(兼容接口的地址 + 模型,Key 单独存)。 */
@@ -698,7 +780,6 @@ export type HobEvent =
698
780
  | { type: "item"; assistantId: string; item: Item } // 新条目,或按 id 替换
699
781
  | { type: "delta"; assistantId: string; itemId: string; text: string } // 流式追加到 assistant 条目
700
782
  | { type: "job"; job: Job }
701
- | { type: "sediment-finished"; jobId: string }
702
783
  | { type: "delegation"; delegation: Delegation }
703
784
  | { type: "job_step"; jobId: string; step: JobStep } // 新的一步,或按 id 替换(输出流式更新、跑完补结果)
704
785
  | { type: "router-activity"; assistantId: string; activity: RouterActivity | null }