Skip to content

Conversation

@OhYee
Copy link
Member

@OhYee OhYee commented Jan 28, 2026

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

OhYee added 3 commits January 29, 2026 21:04
…ompatibility and toolset conversion

This commit introduces a complete integration module that provides compatibility between AgentRun and Mastra frameworks. Key features include:

- Mastra event converter to transform Mastra stream events to AgentRun standard events
- Built-in toolset integration with cross-framework conversion capabilities
- Adapter classes for message, tool, and model compatibility layers
- Sandbox toolsets for code interpreter and browser automation with Playwright support
- Model integration functions for quick creation of common model objects
- Comprehensive README documentation for Mastra integration

The integration enables seamless use of AgentRun resources within Mastra applications and vice versa, supporting text streaming, tool calls, error handling, and multi-protocol communication.

This adds significant functionality for framework interoperability and expands the ecosystem support for both AgentRun and Mastra users.

新增了一个完整的集成模块,提供 AgentRun 和 Mastra 框架之间的兼容性。主要特性包括:

- Mastra 事件转换器,将 Mastra 流式事件转换为 AgentRun 标准事件
- 内置工具集集成,具有跨框架转换功能
- 消息、工具和模型兼容层的适配器类
- 用于代码解释器和浏览器自动化的沙箱工具集,支持 Playwright
- 用于快速创建通用模型对象的模型集成函数
- Mastra 集成的全面 README 文档

该集成实现了 AgentRun 资源在 Mastra 应用中的无缝使用,反之亦然,支持文本流式传输、工具调用、错误处理和多协议通信。

这为框架互操作性添加了重要功能,并扩展了 AgentRun 和 Mastra 用户的生态系统支持。

Change-Id: Ia07388a0e60eef8b55f3e201e37a9179700ae93c
Signed-off-by: OhYee <oyohyee@oyohyee.com>
…and adapters

This introduces a complete server module that includes core infrastructure,
protocol handlers for OpenAI and AG-UI, and Express.js adapters. The new
module provides a unified way to handle agent invocations and stream
responses across different protocols.

Adds core models, invoker logic, and full protocol implementation
supporting both streaming and non-streaming responses.

新增包含协议处理程序和适配器的完整服务器模块。这引入了一个完整的服务器模块,
包括核心基础设施、OpenAI 和 AG-UI 的协议处理程序,以及 Express.js 适配器。
新模块提供了跨不同协议统一处理代理调用和流响应的方法。

添加核心模型、调用器逻辑和完整的协议实现,支持流式和非流式响应。

Change-Id: I02f35f9c83ae08d88bff9d997f893ca62051f376
Signed-off-by: OhYee <oyohyee@oyohyee.com>
…ocess

Add automatic generation of package.json exports for all sub-modules
including agent-runtime, credential, integration, model, sandbox, server,
and toolset. Update build process to run export generation before tsup.
Add new example script and update dependencies.

Automatically scan src directory for index.ts files and generate
corresponding export entries in package.json with proper type, import,
and require paths.

更新包配置以自动为子模块生成导出,并改进构建过程。添加对 agent-runtime、
credential、integration、model、sandbox、server 和 toolset 等子模块的自动导出支持。
更新构建流程以在 tsup 之前运行导出生成。添加新的示例脚本并更新依赖项。

自动扫描 src 目录中的 index.ts 文件,并在 package.json 中生成相应的导出条目,
包含适当的类型、导入和要求路径。

Change-Id: I4be18c5a13dc5de9745bd65e8f6b3c52cc3847cf
Signed-off-by: OhYee <oyohyee@oyohyee.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces Mastra integration for the AgentRun SDK, adding comprehensive server capabilities with multi-protocol support (OpenAI and AG-UI) and framework integration features.

Changes:

  • Added AgentRun HTTP Server with OpenAI and AG-UI protocol support
  • Implemented Mastra framework integration with event converters and tool adapters
  • Created built-in integration modules for models, toolsets, and sandboxes
  • Added comprehensive test coverage for server and integration features

Reviewed changes

Copilot reviewed 42 out of 43 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tsup.config.ts Auto-scan entry points, add chromium-bidi external
tsconfig.json Include examples directory in compilation
package.json Move @mastra/core to devDependencies, add new exports
src/server/* New HTTP server with protocol handlers (OpenAI, AG-UI)
src/integration/* Mastra integration and built-in adapters
tests/unittests/* Comprehensive test coverage for new features
tests/e2e/* E2E test improvements with better error handling
examples/* New examples demonstrating server and tool calling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ve type safety

The version injection mechanism has been updated to provide better fallback
support when the build-time version is not available. The implementation now
includes proper ESM compatibility and error handling for direct execution
scenarios.

Additionally, import ordering has been standardized across multiple files
and type safety has been improved by updating parameter names and interface
definitions to align with current API specifications.

The OpenAI protocol handler has been updated to handle both args_delta and
argsDelta naming conventions for tool call chunks, ensuring compatibility
with different client implementations.

BREAKING CHANGE: The waitUntilReadyOrFailed method now uses 'callback'
parameter instead of 'beforeCheck' for consistency.

更新了版本注入机制,提供了更好的回退支持,当构建时版本不可用时。
实现现在包括适当的ESM兼容性和直接执行场景的错误处理。

此外,多个文件的导入顺序已标准化,通过更新参数名称和接口定义
以与当前API规范保持一致来提高类型安全性。

OpenAI协议处理程序已更新以处理工具调用块的args_delta和argsDelta
命名约定,确保与不同客户端实现的兼容性。

重大变更: waitUntilReadyOrFailed方法现在使用'callback'参数
而不是'beforeCheck'以保持一致性。

Change-Id: Ibd2d266346f9e9f717ce15ad40bb0f79b3fa1741
Signed-off-by: OhYee <oyohyee@oyohyee.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 39 out of 40 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"zod": "^4.2.1"
},
"peerDependencies": {
"@mastra/core": "*"
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The peerDependencies section specifies "@mastra/core": "*" which accepts any version. This is risky as breaking changes in future versions of @mastra/core could break the integration. Consider specifying a more restrictive version range like "^1.0.0" based on the devDependency version.

Suggested change
"@mastra/core": "*"
"@mastra/core": "^1.0.0"

Copilot uses AI. Check for mistakes.
Comment on lines +132 to +133
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const express = require('express');
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dynamic import pattern using require('express') bypasses type checking. Consider using a try-catch with dynamic import() instead: const { Router } = await import('express') to maintain type safety and ESM compatibility.

Copilot uses AI. Check for mistakes.
'uuid',
'zod',
'@mastra/core',
'chromium-bidi',
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency 'chromium-bidi' is added to the external list but is not present in package.json dependencies or devDependencies. This could cause runtime errors if the dependency is expected but not installed.

Copilot uses AI. Check for mistakes.
src/index.ts Outdated
Comment on lines 22 to 24
const { readFileSync } = require('fs');
const { fileURLToPath } = require('url');
const { dirname, join } = require('path');
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VERSION constant initialization uses require() with import.meta.url which is incompatible. In ESM modules, you cannot use require() directly. This code will throw an error at runtime. Consider using dynamic import() instead or a different approach to read the package.json version.

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +34
content: msg.content || '',
}) as any,
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of 'any' type is overly permissive here. The messages parameter should be typed more strictly according to Mastra's expected message format to ensure type safety and catch errors at compile time.

Copilot uses AI. Check for mistakes.
Remove complex fallback mechanism and use direct conditional assignment
for version constant, reducing code complexity while maintaining same
functionality.

简化版本常量实现,移除复杂的回退机制并使用直接条件赋值,
减少代码复杂度同时保持相同功能。

Change-Id: I98ed261c2d6f0c1129fc93fa098c38cf4d612c72
Signed-off-by: OhYee <oyohyee@oyohyee.com>
@OhYee OhYee merged commit 21309a9 into main Jan 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants