tg_claw_kit 0.0.1
tg_claw_kit: ^0.0.1 copied to clipboard
Flutter plugin for Claw auth, hidden webcam env bootstrap, chat session management, and device authorization.
tg_claw_kit #
tg_claw_kit (探鸽龙虾)是一个面向 Flutter 的龙虾实例SDK,主要功能有:
- 鉴权
- 预装探鸽摄像头 Skill 服务(用于查询已绑定设备、查看当前画面、查询事件、查看事件图片、确认设备状态和电量等)
- 最近会话恢复、流式对话
- 设备授权、解绑、授权列表查询
它的外部最小依赖只有两类:
- 业务登录态
accessToken(宿主APP登录之后的令牌,用于换取调用) - 设备授权场景下的
deviceId(需要授权给的设备ID)
安装 #
dependencies:
tg_claw_kit: ^0.0.1
3 行接入 #
await TgClawKit.initialize();
await TgClawKit.auth(accessToken: accessToken);
final TgClawChatHistory? history = await TgClawKit.loadChatHistory();
公共 API #
await TgClawKit.initialize(
authAppId: '5920020',
authPackageName: 'com.tange365.icam365',
);
final TgClawAuthSession session = await TgClawKit.auth(
accessToken: accessToken,
);
final TgClawChatHistory? history = await TgClawKit.loadChatHistory();
await TgClawKit.chat(
'帮我总结最近的设备异常',
onEvent: (TgClawChatEvent event) {},
onError: (TgClawException error) {},
onDone: () {},
);
await TgClawKit.authorize(deviceId: deviceId);
await TgClawKit.revoke(deviceId: deviceId);
final devices = await TgClawKit.getAuthorizationDevices();
await TgClawKit.clearSession();
onEvent 会持续返回 TgClawChatEvent 增量事件,可直接驱动聊天 UI。详细事件定义见 doc/developer-guide.md。
环境切换 #
支持环境切换,管理不同环境下的设备,默认不传 environment 时,等价于 TgClawEnvironment.production。
await TgClawKit.initialize(environment: TgClawEnvironment.production);
await TgClawKit.initialize(environment: TgClawEnvironment.preRelease);
await TgClawKit.initialize(environment: TgClawEnvironment.test);
当前环境策略:
production走正式后端preRelease当前按测试后端映射test走测试后端
Example #
插件 example 工程示例了如何调用 tg_claw_kit API 实现一个龙虾功能,包含鉴权管理、会话管理、设备授权管理等。
cd example
flutter pub get
flutter run
更多接入说明见 doc/developer-guide.md。