@agentrun/sdk 0.0.1-test.eab07a8 → 0.0.2-test.20909811203
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -55
- package/dist/index.cjs +80 -1171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -516
- package/dist/index.d.ts +3 -516
- package/dist/index.js +81 -1160
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -99,59 +99,6 @@ await sandbox.delete();
|
|
|
99
99
|
await template.delete();
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
### Server
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
import { AgentRunServer, AgentRequest } from '@alicloud/agentrun-sdk';
|
|
106
|
-
|
|
107
|
-
// 创建服务器
|
|
108
|
-
const server = new AgentRunServer({
|
|
109
|
-
invokeAgent: async (request: AgentRequest) => {
|
|
110
|
-
const userMessage = request.messages[request.messages.length - 1]?.content;
|
|
111
|
-
return `You said: ${userMessage}`;
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// 启动服务器
|
|
116
|
-
server.start({ port: 9000 });
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
测试:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
curl http://127.0.0.1:9000/openai/v1/chat/completions -X POST \
|
|
123
|
-
-H "Content-Type: application/json" \
|
|
124
|
-
-d '{"messages": [{"role": "user", "content": "Hello!"}]}'
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Mastra 集成
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
import { createMastraAdapter, wrapTools, CanonicalTool } from '@alicloud/agentrun-sdk';
|
|
131
|
-
|
|
132
|
-
// 创建 Mastra 适配器
|
|
133
|
-
const adapter = createMastraAdapter();
|
|
134
|
-
|
|
135
|
-
// 定义工具
|
|
136
|
-
const tools: CanonicalTool[] = [
|
|
137
|
-
{
|
|
138
|
-
name: 'get_weather',
|
|
139
|
-
description: 'Get weather for a location',
|
|
140
|
-
parameters: {
|
|
141
|
-
type: 'object',
|
|
142
|
-
properties: {
|
|
143
|
-
location: { type: 'string', description: 'City name' },
|
|
144
|
-
},
|
|
145
|
-
required: ['location'],
|
|
146
|
-
},
|
|
147
|
-
func: async ({ location }) => `Weather in ${location}: Sunny, 25°C`,
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
// 转换为 Mastra 工具格式
|
|
152
|
-
const mastraTools = wrapTools(tools);
|
|
153
|
-
```
|
|
154
|
-
|
|
155
102
|
## 模块
|
|
156
103
|
|
|
157
104
|
| 模块 | 描述 |
|
|
@@ -160,8 +107,6 @@ const mastraTools = wrapTools(tools);
|
|
|
160
107
|
| **Credential** | 凭证管理 |
|
|
161
108
|
| **Model** | 模型服务和代理管理 |
|
|
162
109
|
| **Sandbox** | 沙箱环境管理 (代码解释器、浏览器) |
|
|
163
|
-
| **Server** | OpenAI 兼容的 HTTP 服务器 |
|
|
164
|
-
| **Integration** | 框架集成 (Mastra) |
|
|
165
110
|
|
|
166
111
|
## 示例
|
|
167
112
|
|