microsoft/skills

m365-agents-ts

用 Express 承载 TypeScript Agent并向 Copilot Studio发问

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

m365-agents-ts 是什么?

此 Skill 介绍 Node/TypeScript 的 Microsoft 365 Agents SDK:Express server、AgentApplication 路由、流式响应、invoke 活动及 Copilot Studio Client/WebChat。模型调用、认证和应用注册需要单独配置。

中文说明由本站依据来源整理;英文原文保留在页面下方。

按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 m365-agents-ts,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 m365-agents-ts

请在 Codex 的当前工作环境中安装并检查 m365-agents-ts 这个 Skill。

项目身份:microsoft/skills / m365-agents-ts
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-typescript/skills/m365-agents-ts/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-typescript/skills/m365-agents-ts/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 安装 @microsoft/agents-hosting、hosting-express、activity 和 copilotstudio-client;按 npm 当前版本核验 APIs。
  • 准备 PORT、Entra租户/client信息、Copilot环境与schema,以及真实token provider。
  • 源文 AZURE_API_KEY 和 COPILOT_BEARER_TOKEN 为示例变量;生产不要将长期服务令牌存浏览器或提交到仓库。

实际使用顺序

  1. 使用 AgentApplication 注册 conversation_update、onMessage 和 invoke handler,再由 startServer 承载。
  2. 需要Azure OpenAI流式答复时配置模型提供者和部署,按 part 类型读取文本,finally结束stream。
  3. invoke活动检查 payload 后才返回约定响应;不可信输入不要直接持久化或写日志。
  4. CopilotStudioClient 的 tokenProvider 从受控后端获取有效短期访问令牌;WebChat前端不能持有长期 secret。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

请按此 Skill 给我一个 TypeScript Agent接入审查方案:检查Express host、message handler、stream endStream、CopilotStudioClient tokenProvider和WebChat敏感凭证边界。只给建议,不安装包、不运行server。
预期结果

得到路由与令牌处理审查项;没有连接外部 Agent 或发起对话。

使用前先看这些限制

使用条件与边界

  • 源文流式Azure示例使用 @ai-sdk/azure 和 AI SDK,需额外安装包并配置endpoint/API version/认证。
  • Copilot Bearer token 若直接写入网页环境变量会暴露给客户端用户。
  • WebChat UI能连接Copilot Studio不等于应用已配置M365渠道认证和授权。
针对这个 Skill 的疑问

常见问题

能把 COPILOT_BEARER_TOKEN 放到前端 .env 吗?

不要。构建后的前端变量对用户可见;由受控后端获取短期令牌,并按文档支持的安全流程连接。

流式响应卡住或不完整怎么办?

确认上游 fullStream 已结束/错误处理,并无论成功失败都调用 endStream;同时记录不含敏感数据的失败原因。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

.github/plugins/azure-sdk-typescript/skills/m365-agents-ts/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

Microsoft 365 Agents SDK for TypeScript/Node.js. Build multichannel agents for Teams/M365/Copilot Studio with AgentApplication routing, Express hosting, streaming responses, and Copilot Studio client integration. Triggers: "Microsoft 365 Agents SDK", "@microsoft/agents-hosting", "AgentApplication", "startServer", "streamingResponse", "Copilot Studio client", "@microsoft/agents-copilotstudio-client".

查看源文件章节 / Source sections
  • 原文:Microsoft 365 Agents SDK (TypeScript)
  • 原文:Before implementation
  • 安装 / Installation
  • 原文:Environment Variables
  • 原文:Core Workflow: Express-hosted AgentApplication
  • 原文:Streaming responses with Azure OpenAI
  • 原文:Invoke activity handling
  • 原文:Copilot Studio client (Direct to Engine)
  • 原文:Copilot Studio WebChat integration
  • 原文:Best Practices
  • 原文:Reference Links
原文:Microsoft 365 Agents SDK (TypeScript)

Build enterprise agents for Microsoft 365, Teams, and Copilot Studio using the Microsoft 365 Agents SDK with Express hosting, AgentApplication routing, streaming responses, and Copilot Studio client integrations.

原文:Before implementation

- Use the microsoft-docs MCP to verify the latest API signatures for AgentApplication, startServer, and CopilotStudioClient. - Confirm package versions on npm before wiring up samples or templates.

安装 / Installation

```bash npm install @microsoft/agents-hosting @microsoft/agents-hosting-express @microsoft/agents-activity npm install @microsoft/agents-copilotstudio-client ```

原文:Environment Variables

```bash PORT=3978 AZURE_RESOURCE_NAME=<azure-openai-resource> AZURE_API_KEY=<azure-openai-key> AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini TENANT_ID=<tenant-id> CLIENT_ID=<client-id> CLIENT_SECRET=<client-secret> COPILOT_ENVIRONMENT_ID=<environment-id> COPILOT_SCHEMA_NAME=<schema-name> COPILOT_CLIENT_ID=<copilot-app-client-id> COPILOT_BEARER_TOKEN=<copilot-jwt> ```

原文:Core Workflow: Express-hosted AgentApplication

```typescript import { AgentApplication, TurnContext, TurnState, } from "@microsoft/agents-hosting"; import { startServer } from "@microsoft/agents-hosting-express"; const agent = new AgentApplication<TurnState>(); agent.onConversationUpdate("membersAdded", async (context: TurnContext) => { await context.sendActivity("Welcome to the agent."); }); agent.onMessage("hello", async (context: TurnContext) => { await context.sendActivity(`Echo: ${context.activity.text}`); }); startServer(agent); ```

原文:Streaming responses with Azure OpenAI

```typescript import { azure } from "@ai-sdk/azure"; import { AgentApplication, TurnContext, TurnState, } from "@microsoft/agents-hosting"; import { startServer } from "@microsoft/agents-hosting-express"; import { streamText } from "ai"; const agent = new AgentApplication<TurnState>(); agent.onMessage("poem", async (context: TurnContext) => { context.streamingResponse.setFeedbackLoop(true); context.streamingResponse.setGeneratedByAILabel(true); context.streamingResponse.setSensitivityLabel({ type: "https://schema.org/Message", "@type": "CreativeWork", name: "Internal", }); await context.streamingResponse.queueInformativeUpdate("starting a poem..."); const { fullStream } = streamText({ model: azure(process.env.AZURE_OPENAI_DEPLOYMENT_NAME || "gpt-4o-mini"), system: "You are a creative assistant.", prompt: "Write a poem about Apollo.", }); try { for await (const part of fullStream) { if (part.type === "text-delta" && part.text.length > 0) { await context.streamingResponse.queueTextChunk(part.text); } if (part.type === "error") { throw new Error(`Streaming error: ${part.error}`); } } } finally { await context.streamingResponse.endStream(); } }); startServer(agent); ```

文件 SHA256:6e4d92ab2e19baa8136419195394789218c2a9157ddd87100cf352870b379bdc

仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。

SKILL.md原文description · 2026-11-16T12:36:35.145Z

Microsoft 365 Agents SDK for TypeScript/Node.js. Build multichannel agents for Teams/M365/Copilot Studio with AgentApplication routing, Express hosting, streaming responses, and Copilot Studio client integration. Triggers: "Microsoft 365 Agents SDK", "@microsoft/agents-hosting", "AgentApplication", "startServer", "streamingResponse", "Copilot Studio client", "@microsoft/agents-copilotstudio-client".

查看历史简介来源

历史收录数据

来源仓库microsoft/skills
Skill源路径.github/plugins/azure-sdk-typescript/skills/m365-agents-ts/SKILL.md

安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源