@kweaver-ai/chatkit 0.1.6 → 0.1.7

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 CHANGED
@@ -484,6 +484,52 @@ interface ChatKitInterface {
484
484
  }
485
485
  ```
486
486
 
487
+ ### BlockRegistry 消息工具注册管理
488
+
489
+ 对除了内置工具以外的工具支持自定义扩展
490
+
491
+ ```typescript
492
+ type ToolBlockRegistration {
493
+ /** 工具名称(唯一标识),对应 ToolCallData.name */
494
+ name: string;
495
+ /** 工具图标,React 元素 */
496
+ Icon?: React.ReactNode;
497
+ /** 工具点击事件
498
+ * @param block 工具块数据,类型为 Record<string, any>
499
+ */
500
+ onClick?: (block: Record<string, any>) => void;
501
+ }
502
+
503
+ // 接口注册方法
504
+ registerTool(registration: ToolBlockRegistration)
505
+
506
+ // 取消注册方法
507
+ unregisterTool(toolName: string)
508
+
509
+ // 获取注册信息
510
+ getTool(toolName: string) => ToolBlockRegistration | undefined
511
+
512
+ // 查询工具是否已经注册
513
+ hasTool(toolName: string) => boolean
514
+ // 所欲注册工具
515
+ clearAll()
516
+
517
+ // 获取所有已注册功德名称
518
+ getAllToolNames() => string[]
519
+ ```
520
+ 示例
521
+
522
+ ```typescript
523
+ BlockRegistry.registerTool({
524
+ name: 'your_tool_name',
525
+ Icon: <YourIcon />,
526
+ onClick: (block) => {
527
+ // 自定义处理逻辑
528
+ },
529
+ });
530
+ ```
531
+
532
+
487
533
  ## 架构设计
488
534
 
489
535
  ### Mixin 模式