@agentrun/sdk 0.0.1-test.21dd786

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.
Files changed (127) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +225 -0
  3. package/dist/add.d.ts +2 -0
  4. package/dist/add.d.ts.map +1 -0
  5. package/dist/agent-runtime/api/control.d.ts +190 -0
  6. package/dist/agent-runtime/api/control.d.ts.map +1 -0
  7. package/dist/agent-runtime/api/data.d.ts +38 -0
  8. package/dist/agent-runtime/api/data.d.ts.map +1 -0
  9. package/dist/agent-runtime/api/index.d.ts +5 -0
  10. package/dist/agent-runtime/api/index.d.ts.map +1 -0
  11. package/dist/agent-runtime/client.d.ts +146 -0
  12. package/dist/agent-runtime/client.d.ts.map +1 -0
  13. package/dist/agent-runtime/endpoint.d.ts +132 -0
  14. package/dist/agent-runtime/endpoint.d.ts.map +1 -0
  15. package/dist/agent-runtime/index.d.ts +12 -0
  16. package/dist/agent-runtime/index.d.ts.map +1 -0
  17. package/dist/agent-runtime/model.d.ts +327 -0
  18. package/dist/agent-runtime/model.d.ts.map +1 -0
  19. package/dist/agent-runtime/runtime.d.ts +206 -0
  20. package/dist/agent-runtime/runtime.d.ts.map +1 -0
  21. package/dist/credential/api/control.d.ts +90 -0
  22. package/dist/credential/api/control.d.ts.map +1 -0
  23. package/dist/credential/api/index.d.ts +5 -0
  24. package/dist/credential/api/index.d.ts.map +1 -0
  25. package/dist/credential/client.d.ts +57 -0
  26. package/dist/credential/client.d.ts.map +1 -0
  27. package/dist/credential/credential.d.ts +68 -0
  28. package/dist/credential/credential.d.ts.map +1 -0
  29. package/dist/credential/index.d.ts +9 -0
  30. package/dist/credential/index.d.ts.map +1 -0
  31. package/dist/credential/model.d.ts +132 -0
  32. package/dist/credential/model.d.ts.map +1 -0
  33. package/dist/index.cjs +7498 -0
  34. package/dist/index.d.ts +32 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +7493 -0
  37. package/dist/integration/adapter.d.ts +128 -0
  38. package/dist/integration/adapter.d.ts.map +1 -0
  39. package/dist/integration/index.d.ts +14 -0
  40. package/dist/integration/index.d.ts.map +1 -0
  41. package/dist/integration/mastra/adapter.d.ts +112 -0
  42. package/dist/integration/mastra/adapter.d.ts.map +1 -0
  43. package/dist/integration/mastra/index.d.ts +15 -0
  44. package/dist/integration/mastra/index.d.ts.map +1 -0
  45. package/dist/integration/mastra/types.d.ts +62 -0
  46. package/dist/integration/mastra/types.d.ts.map +1 -0
  47. package/dist/model/api/control.d.ts +162 -0
  48. package/dist/model/api/control.d.ts.map +1 -0
  49. package/dist/model/client.d.ts +91 -0
  50. package/dist/model/client.d.ts.map +1 -0
  51. package/dist/model/index.d.ts +10 -0
  52. package/dist/model/index.d.ts.map +1 -0
  53. package/dist/model/model-proxy.d.ts +186 -0
  54. package/dist/model/model-proxy.d.ts.map +1 -0
  55. package/dist/model/model-service.d.ts +185 -0
  56. package/dist/model/model-service.d.ts.map +1 -0
  57. package/dist/model/model.d.ts +227 -0
  58. package/dist/model/model.d.ts.map +1 -0
  59. package/dist/sandbox/aio-sandbox.d.ts +258 -0
  60. package/dist/sandbox/aio-sandbox.d.ts.map +1 -0
  61. package/dist/sandbox/api/aio-data.d.ts +53 -0
  62. package/dist/sandbox/api/aio-data.d.ts.map +1 -0
  63. package/dist/sandbox/api/browser-data.d.ts +85 -0
  64. package/dist/sandbox/api/browser-data.d.ts.map +1 -0
  65. package/dist/sandbox/api/code-interpreter-data.d.ts +189 -0
  66. package/dist/sandbox/api/code-interpreter-data.d.ts.map +1 -0
  67. package/dist/sandbox/api/control.d.ts +146 -0
  68. package/dist/sandbox/api/control.d.ts.map +1 -0
  69. package/dist/sandbox/api/sandbox-data.d.ts +168 -0
  70. package/dist/sandbox/api/sandbox-data.d.ts.map +1 -0
  71. package/dist/sandbox/browser-sandbox.d.ts +98 -0
  72. package/dist/sandbox/browser-sandbox.d.ts.map +1 -0
  73. package/dist/sandbox/client.d.ts +122 -0
  74. package/dist/sandbox/client.d.ts.map +1 -0
  75. package/dist/sandbox/code-interpreter-sandbox.d.ts +238 -0
  76. package/dist/sandbox/code-interpreter-sandbox.d.ts.map +1 -0
  77. package/dist/sandbox/index.d.ts +16 -0
  78. package/dist/sandbox/index.d.ts.map +1 -0
  79. package/dist/sandbox/model.d.ts +231 -0
  80. package/dist/sandbox/model.d.ts.map +1 -0
  81. package/dist/sandbox/sandbox.d.ts +90 -0
  82. package/dist/sandbox/sandbox.d.ts.map +1 -0
  83. package/dist/sandbox/template.d.ts +118 -0
  84. package/dist/sandbox/template.d.ts.map +1 -0
  85. package/dist/server/agui-protocol.d.ts +127 -0
  86. package/dist/server/agui-protocol.d.ts.map +1 -0
  87. package/dist/server/index.d.ts +8 -0
  88. package/dist/server/index.d.ts.map +1 -0
  89. package/dist/server/model.d.ts +150 -0
  90. package/dist/server/model.d.ts.map +1 -0
  91. package/dist/server/server.d.ts +66 -0
  92. package/dist/server/server.d.ts.map +1 -0
  93. package/dist/toolset/api/control.d.ts +74 -0
  94. package/dist/toolset/api/control.d.ts.map +1 -0
  95. package/dist/toolset/api/index.d.ts +10 -0
  96. package/dist/toolset/api/index.d.ts.map +1 -0
  97. package/dist/toolset/api/mcp.d.ts +85 -0
  98. package/dist/toolset/api/mcp.d.ts.map +1 -0
  99. package/dist/toolset/client.d.ts +65 -0
  100. package/dist/toolset/client.d.ts.map +1 -0
  101. package/dist/toolset/index.d.ts +15 -0
  102. package/dist/toolset/index.d.ts.map +1 -0
  103. package/dist/toolset/model.d.ts +246 -0
  104. package/dist/toolset/model.d.ts.map +1 -0
  105. package/dist/toolset/openapi.d.ts +174 -0
  106. package/dist/toolset/openapi.d.ts.map +1 -0
  107. package/dist/toolset/toolset.d.ts +161 -0
  108. package/dist/toolset/toolset.d.ts.map +1 -0
  109. package/dist/utils/config.d.ts +124 -0
  110. package/dist/utils/config.d.ts.map +1 -0
  111. package/dist/utils/control-api.d.ts +24 -0
  112. package/dist/utils/control-api.d.ts.map +1 -0
  113. package/dist/utils/data-api.d.ts +163 -0
  114. package/dist/utils/data-api.d.ts.map +1 -0
  115. package/dist/utils/exception.d.ts +67 -0
  116. package/dist/utils/exception.d.ts.map +1 -0
  117. package/dist/utils/helper.d.ts +2 -0
  118. package/dist/utils/helper.d.ts.map +1 -0
  119. package/dist/utils/index.d.ts +9 -0
  120. package/dist/utils/index.d.ts.map +1 -0
  121. package/dist/utils/log.d.ts +25 -0
  122. package/dist/utils/log.d.ts.map +1 -0
  123. package/dist/utils/model.d.ts +77 -0
  124. package/dist/utils/model.d.ts.map +1 -0
  125. package/dist/utils/resource.d.ts +72 -0
  126. package/dist/utils/resource.d.ts.map +1 -0
  127. package/package.json +98 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Serverless Devs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # AgentRun SDK for Node.js
2
+
3
+ AgentRun SDK 是阿里云 AgentRun 服务的 Node.js 客户端库,为 AI Agent 应用提供托管的运行环境。
4
+
5
+ ## 特性
6
+
7
+ - 🚀 **Agent Runtime**: 创建、管理和部署 AI Agent
8
+ - 📜 **Credential**: 安全的凭证管理
9
+ - 🔧 **Model**: 模型服务和代理管理
10
+ - 📦 **Sandbox**: 代码解释器和浏览器沙箱
11
+ - 🌐 **Server**: OpenAI 兼容的 HTTP 服务器
12
+ - 🔌 **Integration**: Mastra 框架集成
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ npm install @alicloud/agentrun-sdk
18
+ ```
19
+
20
+ ## 快速开始
21
+
22
+ ### 配置
23
+
24
+ SDK 支持从环境变量或代码中配置:
25
+
26
+ ```typescript
27
+ import { Config } from '@alicloud/agentrun-sdk';
28
+
29
+ // 从环境变量读取配置
30
+ // AGENTRUN_ACCESS_KEY_ID
31
+ // AGENTRUN_ACCESS_KEY_SECRET
32
+ // AGENTRUN_ACCOUNT_ID
33
+ // AGENTRUN_REGION (默认: cn-hangzhou)
34
+ const config = new Config();
35
+
36
+ // 或者直接传入配置
37
+ const config = new Config({
38
+ accessKeyId: 'your-access-key-id',
39
+ accessKeySecret: 'your-access-key-secret',
40
+ accountId: 'your-account-id',
41
+ regionId: 'cn-hangzhou',
42
+ });
43
+ ```
44
+
45
+ ### Agent Runtime
46
+
47
+ ```typescript
48
+ import { AgentRuntime, AgentRuntimeLanguage } from '@alicloud/agentrun-sdk';
49
+
50
+ // 创建 Agent Runtime
51
+ const runtime = await AgentRuntime.create({
52
+ agentRuntimeName: 'my-agent',
53
+ codeConfiguration: {
54
+ language: AgentRuntimeLanguage.NODEJS18,
55
+ command: ['node', 'index.js'],
56
+ zipFile: 'base64-encoded-zip',
57
+ },
58
+ });
59
+
60
+ // 等待就绪
61
+ await runtime.waitUntilReady();
62
+
63
+ // 创建端点
64
+ const endpoint = await runtime.createEndpoint({
65
+ agentRuntimeEndpointName: 'default',
66
+ });
67
+
68
+ await endpoint.waitUntilReady();
69
+ console.log('Endpoint URL:', endpoint.endpointPublicUrl);
70
+
71
+ // 删除
72
+ await runtime.delete();
73
+ ```
74
+
75
+ ### Sandbox
76
+
77
+ ```typescript
78
+ import { SandboxClient, TemplateType } from '@alicloud/agentrun-sdk';
79
+
80
+ const client = new SandboxClient();
81
+
82
+ // 创建模板
83
+ const template = await client.createTemplate({
84
+ templateName: 'my-template',
85
+ templateType: TemplateType.CODE_INTERPRETER,
86
+ });
87
+
88
+ await template.waitUntilReady();
89
+
90
+ // 创建沙箱
91
+ const sandbox = await client.createCodeInterpreterSandbox(template.templateName!);
92
+ await sandbox.waitUntilRunning();
93
+
94
+ // 执行代码 (需要数据 API 支持)
95
+ // const result = await sandbox.executeCode('print("Hello!")');
96
+
97
+ // 删除
98
+ await sandbox.delete();
99
+ await template.delete();
100
+ ```
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
+ ## 模块
156
+
157
+ | 模块 | 描述 |
158
+ |------|------|
159
+ | **AgentRuntime** | Agent 运行时管理 |
160
+ | **Credential** | 凭证管理 |
161
+ | **Model** | 模型服务和代理管理 |
162
+ | **Sandbox** | 沙箱环境管理 (代码解释器、浏览器) |
163
+ | **Server** | OpenAI 兼容的 HTTP 服务器 |
164
+ | **Integration** | 框架集成 (Mastra) |
165
+
166
+ ## 示例
167
+
168
+ 运行示例:
169
+
170
+ ```bash
171
+ # 快速开始 - 启动 Agent 服务器
172
+ npm run example:quick-start
173
+
174
+ # Agent Runtime 示例
175
+ npm run example:agent-runtime
176
+
177
+ # Credential 示例
178
+ npm run example:credential
179
+
180
+ # Sandbox 示例
181
+ npm run example:sandbox
182
+ ```
183
+
184
+ ## 开发
185
+
186
+ ```bash
187
+ # 安装依赖
188
+ npm install
189
+
190
+ # 运行测试
191
+ npm test
192
+
193
+ # 运行带覆盖率的测试
194
+ npm run test:coverage
195
+
196
+ # 构建
197
+ npm run build
198
+
199
+ # 类型检查
200
+ npm run typecheck
201
+
202
+ # 代码检查
203
+ npm run lint
204
+ npm run lint:fix
205
+ ```
206
+
207
+ ## 环境变量
208
+
209
+ | 变量 | 描述 | 默认值 |
210
+ |------|------|--------|
211
+ | `AGENTRUN_ACCESS_KEY_ID` | 阿里云 Access Key ID | - |
212
+ | `AGENTRUN_ACCESS_KEY_SECRET` | 阿里云 Access Key Secret | - |
213
+ | `AGENTRUN_ACCOUNT_ID` | 阿里云账号 ID | - |
214
+ | `AGENTRUN_REGION` | 区域 ID | `cn-hangzhou` |
215
+ | `AGENTRUN_TIMEOUT` | API 超时时间 (毫秒) | `600000` |
216
+
217
+ ## 兼容性
218
+
219
+ - Node.js 18.x, 20.x, 22.x
220
+ - TypeScript 5.x
221
+ - 同时支持 CommonJS 和 ESM
222
+
223
+ ## License
224
+
225
+ Apache-2.0
package/dist/add.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function add(a: number, b: number): number;
2
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * This file is auto generated by the code generation script.
3
+ * Do not modify this file manually.
4
+ * Use the `bun run codegen` command to regenerate.
5
+ *
6
+ * 当前文件为自动生成的控制 API 客户端代码。请勿手动修改此文件。
7
+ * 使用 `bun run codegen` 命令重新生成。
8
+ */
9
+ import * as $AgentRun from "@alicloud/agentrun20250910";
10
+ import { Config } from "../../utils/config";
11
+ import { ControlAPI } from "../../utils/control-api";
12
+ /**
13
+ * Agent Runtime Control API
14
+ */
15
+ export declare class AgentRuntimeControlAPI extends ControlAPI {
16
+ constructor(config?: Config);
17
+ /**
18
+ * Create Agent Runtime
19
+ *
20
+ * @param params - Method parameters
21
+ * @param params.input - Agent Runtime configuration
22
+ * @param params.headers - Custom request headers
23
+ * @param params.config - Optional config override
24
+ * @returns Created Runtime object
25
+ */
26
+ createAgentRuntime: (params: {
27
+ input: $AgentRun.CreateAgentRuntimeInput;
28
+ headers?: Record<string, string>;
29
+ config?: Config;
30
+ }) => Promise<$AgentRun.AgentRuntime>;
31
+ /**
32
+ * Delete Agent Runtime
33
+ *
34
+ * @param params - Method parameters
35
+ * @param params.agentId - Agent Runtime ID
36
+ * @param params.headers - Custom request headers
37
+ * @param params.config - Optional config override
38
+ * @returns Deleted Runtime object
39
+ */
40
+ deleteAgentRuntime: (params: {
41
+ agentId: string;
42
+ headers?: Record<string, string>;
43
+ config?: Config;
44
+ }) => Promise<$AgentRun.AgentRuntime>;
45
+ /**
46
+ * Update Agent Runtime
47
+ *
48
+ * @param params - Method parameters
49
+ * @param params.agentId - Agent Runtime ID
50
+ * @param params.input - Agent Runtime configuration
51
+ * @param params.headers - Custom request headers
52
+ * @param params.config - Optional config override
53
+ * @returns Updated Runtime object
54
+ */
55
+ updateAgentRuntime: (params: {
56
+ agentId: string;
57
+ input: $AgentRun.UpdateAgentRuntimeInput;
58
+ headers?: Record<string, string>;
59
+ config?: Config;
60
+ }) => Promise<$AgentRun.AgentRuntime>;
61
+ /**
62
+ * Get Agent Runtime
63
+ *
64
+ * @param params - Method parameters
65
+ * @param params.agentId - Agent Runtime ID
66
+ * @param params.request - Get request options
67
+ * @param params.headers - Custom request headers
68
+ * @param params.config - Optional config override
69
+ * @returns Runtime object
70
+ */
71
+ getAgentRuntime: (params: {
72
+ agentId: string;
73
+ request?: $AgentRun.GetAgentRuntimeRequest;
74
+ headers?: Record<string, string>;
75
+ config?: Config;
76
+ }) => Promise<$AgentRun.AgentRuntime>;
77
+ /**
78
+ * List Agent Runtimes
79
+ *
80
+ * @param params - Method parameters
81
+ * @param params.input - List options
82
+ * @param params.headers - Custom request headers
83
+ * @param params.config - Optional config override
84
+ * @returns List of Runtime objects
85
+ */
86
+ listAgentRuntimes: (params: {
87
+ input: $AgentRun.ListAgentRuntimesRequest;
88
+ headers?: Record<string, string>;
89
+ config?: Config;
90
+ }) => Promise<$AgentRun.ListAgentRuntimesOutput>;
91
+ /**
92
+ * Create Agent Runtime Endpoint
93
+ *
94
+ * @param params - Method parameters
95
+ * @param params.agentId - Agent Runtime ID
96
+ * @param params.input - Endpoint configuration
97
+ * @param params.headers - Custom request headers
98
+ * @param params.config - Optional config override
99
+ * @returns Created Endpoint object
100
+ */
101
+ createAgentRuntimeEndpoint: (params: {
102
+ agentId: string;
103
+ input: $AgentRun.CreateAgentRuntimeEndpointInput;
104
+ headers?: Record<string, string>;
105
+ config?: Config;
106
+ }) => Promise<$AgentRun.AgentRuntimeEndpoint>;
107
+ /**
108
+ * Delete Agent Runtime Endpoint
109
+ *
110
+ * @param params - Method parameters
111
+ * @param params.agentId - Agent Runtime ID
112
+ * @param params.endpointId - Endpoint ID
113
+ * @param params.headers - Custom request headers
114
+ * @param params.config - Optional config override
115
+ * @returns Deleted Endpoint object
116
+ */
117
+ deleteAgentRuntimeEndpoint: (params: {
118
+ agentId: string;
119
+ endpointId: string;
120
+ headers?: Record<string, string>;
121
+ config?: Config;
122
+ }) => Promise<$AgentRun.AgentRuntimeEndpoint>;
123
+ /**
124
+ * Update Agent Runtime Endpoint
125
+ *
126
+ * @param params - Method parameters
127
+ * @param params.agentId - Agent Runtime ID
128
+ * @param params.endpointId - Endpoint ID
129
+ * @param params.input - Endpoint configuration
130
+ * @param params.headers - Custom request headers
131
+ * @param params.config - Optional config override
132
+ * @returns Updated Endpoint object
133
+ */
134
+ updateAgentRuntimeEndpoint: (params: {
135
+ agentId: string;
136
+ endpointId: string;
137
+ input: $AgentRun.UpdateAgentRuntimeEndpointInput;
138
+ headers?: Record<string, string>;
139
+ config?: Config;
140
+ }) => Promise<$AgentRun.AgentRuntimeEndpoint>;
141
+ /**
142
+ * Get Agent Runtime Endpoint
143
+ *
144
+ * @param params - Method parameters
145
+ * @param params.agentId - Agent Runtime ID
146
+ * @param params.endpointId - Endpoint ID
147
+ * @param params.headers - Custom request headers
148
+ * @param params.config - Optional config override
149
+ * @returns Endpoint object
150
+ */
151
+ getAgentRuntimeEndpoint: (params: {
152
+ agentId: string;
153
+ endpointId: string;
154
+ headers?: Record<string, string>;
155
+ config?: Config;
156
+ }) => Promise<$AgentRun.AgentRuntimeEndpoint>;
157
+ /**
158
+ * List Agent Runtime Endpoints
159
+ *
160
+ * @param params - Method parameters
161
+ * @param params.agentId - Agent Runtime ID
162
+ * @param params.input - List options
163
+ * @param params.headers - Custom request headers
164
+ * @param params.config - Optional config override
165
+ * @returns List of Endpoint objects
166
+ */
167
+ listAgentRuntimeEndpoints: (params: {
168
+ agentId: string;
169
+ input: $AgentRun.ListAgentRuntimeEndpointsRequest;
170
+ headers?: Record<string, string>;
171
+ config?: Config;
172
+ }) => Promise<$AgentRun.ListAgentRuntimeEndpointsOutput>;
173
+ /**
174
+ * List Agent Runtime Versions
175
+ *
176
+ * @param params - Method parameters
177
+ * @param params.agentId - Agent Runtime ID
178
+ * @param params.input - List options
179
+ * @param params.headers - Custom request headers
180
+ * @param params.config - Optional config override
181
+ * @returns List of Version objects
182
+ */
183
+ listAgentRuntimeVersions: (params: {
184
+ agentId: string;
185
+ input: $AgentRun.ListAgentRuntimeVersionsRequest;
186
+ headers?: Record<string, string>;
187
+ config?: Config;
188
+ }) => Promise<$AgentRun.ListAgentRuntimeVersionsOutput>;
189
+ }
190
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../src/agent-runtime/api/control.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,SAAS,MAAM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AAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAkC3K;IAEF;;;;;;;;;OASG;IACH,yBAAyB,GAAU,QAAQ;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAC,gCAAgC,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAkCvN;IAEF;;;;;;;;;OASG;IACH,wBAAwB,GAAU,QAAQ;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAC,+BAA+B,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAkCpN;CAEH"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Agent Runtime Data API
3
+ *
4
+ * 此模块定义 Agent Runtime 的数据 API,用于调用 Agent Runtime 实例。
5
+ * This module defines the Data API for Agent Runtime, used to invoke Agent Runtime instances.
6
+ */
7
+ import type { ChatCompletionMessageParam } from "openai/resources";
8
+ import { Config } from "../../utils/config";
9
+ import { DataAPI } from "../../utils/data-api";
10
+ /**
11
+ * Invoke arguments for OpenAI-compatible API
12
+ */
13
+ export interface InvokeArgs {
14
+ /** Chat messages */
15
+ messages: ChatCompletionMessageParam[];
16
+ /** Whether to stream the response */
17
+ stream?: boolean;
18
+ /** Optional config override */
19
+ config?: Config;
20
+ }
21
+ /**
22
+ * Agent Runtime Data API for invoking agent runtime through OpenAI-compatible API
23
+ */
24
+ export declare class AgentRuntimeDataAPI extends DataAPI {
25
+ constructor(agentRuntimeName: string, agentRuntimeEndpointName?: string, config?: Config);
26
+ /**
27
+ * Invoke agent runtime using OpenAI-compatible API
28
+ */
29
+ invokeOpenai(args: InvokeArgs): Promise<(import("openai/core/streaming").Stream<import("openai/resources").ChatCompletionChunk> & {
30
+ _request_id?: string | null;
31
+ }) | (import("openai/resources").ChatCompletion & {
32
+ _request_id?: string | null;
33
+ })>;
34
+ private getConfig;
35
+ private getResourceName;
36
+ private getAuthHeaders;
37
+ }
38
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/agent-runtime/api/data.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAgB,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,OAAO;gBAE5C,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,GAAE,MAAkB,EAC5C,MAAM,CAAC,EAAE,MAAM;IAUjB;;OAEG;IACG,YAAY,CAAC,IAAI,EAAE,UAAU;;;;;IA6BnC,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,eAAe;YAIT,cAAc;CAa7B"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Agent Runtime API exports
3
+ */
4
+ export { AgentRuntimeControlAPI } from "./control";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-runtime/api/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC"}