npm.io
0.12.2 • Published 2d ago

@cuylabs/channel-teams-agent-core

Licence
Apache-2.0
Version
0.12.2
Deps
3
Size
56 kB
Vulns
0
Weekly
0

@cuylabs/channel-teams-agent-core

Teams adapter for @cuylabs/agent-core, built on top of @cuylabs/channel-teams and @cuylabs/channel-m365-agent-core.

Use this package when a Teams bot should run an agent-core-compatible turn source and still expose Teams-specific invoke handlers, routing metadata, targeted activity helpers, and proactive conversation capture.

Install

npm install @cuylabs/channel-teams-agent-core @cuylabs/agent-core @microsoft/agents-hosting @microsoft/agents-hosting-extensions-teams express

Mount A Teams Agent

import { createAgent } from "@cuylabs/agent-core";
import { mountTeamsAgent } from "@cuylabs/channel-teams-agent-core";

const agent = createAgent({
  model,
});

await mountTeamsAgent(agent, {
  path: "/api/messages",
  handlers: {
    async searchCommand(ctx) {
      await ctx.sendInvoke({
        composeExtension: {
          type: "message",
          text: `Search: ${ctx.turnContext.activity.value?.query ?? ""}`,
        },
      });
    },
  },
});

Adapter Layer

import { createTeamsChannelAdapter } from "@cuylabs/channel-teams-agent-core";

const teams = createTeamsChannelAdapter({
  source: agent,
  prepareTurn({ teams }) {
    return {
      scopeName: "teams-activity",
      scopeAttributes: {
        teamsKind: teams.kind,
        teamsSurface: teams.surface,
      },
      context: { teams },
    };
  },
});

Proactive Messaging

import {
  captureTeamsConversationReference,
  continueM365Conversation,
} from "@cuylabs/channel-teams-agent-core/proactive";

const capture = captureTeamsConversationReference(turnContext);

await continueM365Conversation(adapter, capture.conversation, async (ctx) => {
  await ctx.sendActivity("Done");
});

Package Boundary

Use @cuylabs/channel-teams for Teams parsing and response helpers without an agent runtime. Use this package when you want the Teams adapter that binds those helpers to @cuylabs/agent-core.

Keywords