npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bdky/aaas-pilot-kit-vue3

v1.1.13

Published

百度数字员工 AaaS Pilot Kit 的 Vue 3 封装,提供 Composables 和依赖注入支持

Readme

介绍

专为 Vue 3 应用优化的 AaaS Pilot Kit SDK,基于 Composition API 和依赖注入设计。

特性

  • 🪝 Composition API - useAaaSPilotKituseConversationuseConversationList 等组合式函数
  • 🎯 依赖注入 - provideAaaSPilotKit 遵循 Vue 3 provide/inject 标准范式,管理全局状态,实现跨组件状态共享
  • 📦 TypeScript 支持 - 完整的类型定义,与核心库类型保持一致
  • 性能优化 - 内置响应式状态管理,自动处理控制器生命周期
  • 🔄 事件系统 - 简化的事件监听接口,支持流式内容更新
  • 💡 Vue 3 原生 - 充分利用 Vue 3 的响应式系统和组合式 API

安装

npm

$ npm install @bdky/aaas-pilot-kit-vue3

yarn

$ yarn add @bdky/aaas-pilot-kit-vue3

核心 API

Provider 和依赖注入

| 函数 | 功能 | 使用场景 | |------|------|----------| | provideAaaSPilotKit | 创建并提供控制器实例 | 根组件中初始化 | | useAaaSPilotKit | 获取控制器和状态 | 子组件中访问功能 | | injectAaaSPilotKit | 底层依赖注入函数 | 高级用法和自定义封装 |

核心 Composables

| Composable | 功能 | 返回值 | |------------|------|--------| | useAaaSPilotKit | 获取控制器和状态 | {controller, isReady, isMuted, isRendering, create, dispose} | | useAaaSPilotKitEvents | 绑定事件监听器 | void | | useConversationList | 获取对话列表 | {conversationList} | | useConversation | 处理单个对话内容 | {conversationContents} |

事件处理

简化的事件监听接口,支持所有核心库事件:

<script setup lang="ts">
    useAaaSPilotKitEvents({
        onReady: () => console.log('就绪'),
        onAsrMessage: (payload) => console.log('ASR结果:', payload.text),
        onRenderStart: (payload) => console.log('开始渲染:', payload),
        onConversationChange: (payload) => updateUI(payload)
    });
</script>

高级功能

自定义 AgentService

当需要接入私有 Agent 流式 API 协议时,可以通过继承 BaseAgentService 来创建自定义的 Agent 服务类:

<script setup lang="ts">
    import {provideAaaSPilotKit} from '@bdky/aaas-pilot-kit-vue3';
    
    const options = {
        figureId: '209337',
        agentService: CustomAgentService // 替代 agentConfig
    };
    
    // 传入自定义 AgentService
    provideAaaSPilotKit(options);
</script>

⚠️ 注意:使用自定义 agentService 时,无需再配置 agentConfig,以避免混用带来的歧义。

详细实现指南自定义 AgentService 配置

流式对话渲染

父组件 - 获取对话列表

<template>
    <div>
        <ConversationItem
            v-for="conversation in conversationList"
            :key="conversation.id"
            :conversation="conversation"
        />
    </div>
</template>

<script setup lang="ts">
    import {useConversationList} from '@bdky/aaas-pilot-kit-vue3';
    import ConversationItem from './ConversationItem.vue';
    
    const {conversationList} = useConversationList();
</script>

子组件 - 渲染单个对话内容

<template>
    <div>
        <div
            v-for="item in conversationContents"
            :key="item.uiId"
            :class="['message', item.mod]"
        >
            <strong>{{ item.mod }}</strong>
            <div>{{ item.content }}</div>
            <span>{{ item.completed ? '完成' : '进行中' }}</span>
        </div>
    </div>
</template>

<script setup lang="ts">
    import {useConversation} from '@bdky/aaas-pilot-kit-vue3';
    import {toRef} from 'vue';
    import type {AnyConversation} from '@bdky/aaas-pilot-kit';
    
    const props = defineProps<{
        conversation: AnyConversation | undefined;
    }>();
    
    const {conversationContents} = useConversation(toRef(props, 'conversation'));
</script>

💡 为什么需要 toRef

由于 conversation 是通过 props 传入的,直接解构 props.conversation 会丢失响应性。使用 toRef(props, 'conversation') 可以创建一个指向 props 属性的 ref,确保当父组件传入的 conversation 变化时,useConversation 能够响应式地更新 conversationContents

生命周期管理

<script setup lang="ts">
    import {nextTick} from 'vue';
    import {useAaaSPilotKit} from '@bdky/aaas-pilot-kit-vue3';
    
    const {controller, create, dispose} = useAaaSPilotKit();
    // 手动控制生命周期
    const restartSession = async () => {
        dispose();
        await nextTick();
        create();
    };
</script>

❓ 帮助与支持

遇到问题或有建议?欢迎通过以下方式联系我们: