@@ -88,12 +88,12 @@ async function createOrGetAgentRuntime(): Promise<AgentRuntime> {
8888 codeConfiguration : await codeFromFile (
8989 AgentRuntimeLanguage . NODEJS18 ,
9090 [ 'node' , 'index.js' ] ,
91- codePath ,
91+ codePath
9292 ) ,
9393 port : 9000 ,
9494 cpu : 2 ,
9595 memory : 4096 ,
96- }
96+ } ,
9797 } ) ;
9898
9999 log ( `创建成功 / Created successfully: ${ ar . agentRuntimeId } ` ) ;
@@ -113,10 +113,10 @@ async function createOrGetAgentRuntime(): Promise<AgentRuntime> {
113113 ar . status === Status . DELETE_FAILED
114114 ) {
115115 log (
116- `已存在的 Agent Runtime 处于失败状态: ${ ar . status } , 删除并重新创建 / Existing Agent Runtime is in failed state: ${ ar . status } , deleting and recreating` ,
116+ `已存在的 Agent Runtime 处于失败状态: ${ ar . status } , 删除并重新创建 / Existing Agent Runtime is in failed state: ${ ar . status } , deleting and recreating`
117117 ) ;
118118 await ar . delete ( ) ;
119-
119+
120120 // Wait for deletion to complete
121121 log ( '等待删除完成 / Waiting for deletion to complete...' ) ;
122122 let deleted = false ;
@@ -134,7 +134,7 @@ async function createOrGetAgentRuntime(): Promise<AgentRuntime> {
134134 break ;
135135 }
136136 }
137-
137+
138138 if ( ! deleted ) {
139139 throw new Error ( '等待删除超时 / Deletion timeout' ) ;
140140 }
@@ -155,20 +155,21 @@ async function createOrGetAgentRuntime(): Promise<AgentRuntime> {
155155 codeConfiguration : await codeFromFile (
156156 AgentRuntimeLanguage . NODEJS18 ,
157157 [ 'node' , 'index.js' ] ,
158- codePath ,
158+ codePath
159159 ) ,
160160 port : 9000 ,
161161 cpu : 2 ,
162162 memory : 4096 ,
163- }
163+ } ,
164164 } ) ;
165165 log ( `创建成功 / Created successfully: ${ ar . agentRuntimeId } ` ) ;
166166 }
167167
168168 // Wait for ready or failed
169169 log ( '等待就绪 / Waiting for ready...' ) ;
170170 await ar . waitUntilReadyOrFailed ( {
171- beforeCheck : ( runtime ) => log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
171+ callback : ( runtime ) =>
172+ log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
172173 } ) ;
173174
174175 if ( ar . status !== Status . READY ) {
@@ -196,7 +197,8 @@ async function updateAgentRuntime(ar: AgentRuntime): Promise<void> {
196197 } ) ;
197198
198199 await ar . waitUntilReadyOrFailed ( {
199- beforeCheck : ( runtime ) => log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
200+ callback : ( runtime ) =>
201+ log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
200202 } ) ;
201203
202204 if ( ar . status !== Status . READY ) {
@@ -213,10 +215,10 @@ async function updateAgentRuntime(ar: AgentRuntime): Promise<void> {
213215async function listAgentRuntimes ( ) : Promise < void > {
214216 log ( '枚举资源列表 / Listing resources' ) ;
215217
216- const runtimes = await client . listAll ( ) ;
218+ const runtimes = await AgentRuntime . listAll ( ) ;
217219 log (
218220 `共有 ${ runtimes . length } 个资源 / Total ${ runtimes . length } resources:` ,
219- runtimes . map ( ( r ) => r . agentRuntimeName ) ,
221+ runtimes . map ( ( r ) => r . agentRuntimeName )
220222 ) ;
221223}
222224
@@ -232,8 +234,9 @@ async function deleteAgentRuntime(ar: AgentRuntime): Promise<void> {
232234 // Wait for deletion
233235 log ( '等待删除完成 / Waiting for deletion...' ) ;
234236 try {
235- await ar . waitUntilReady ( {
236- beforeCheck : ( runtime ) => log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
237+ await ar . waitUntilReadyOrFailed ( {
238+ callback : ( runtime ) =>
239+ log ( ` 当前状态 / Current status: ${ runtime . status } ` ) ,
237240 } ) ;
238241 } catch ( error ) {
239242 // Expected to fail when resource is deleted
@@ -245,7 +248,9 @@ async function deleteAgentRuntime(ar: AgentRuntime): Promise<void> {
245248 log ( '资源仍然存在 / Resource still exists' ) ;
246249 } catch ( error ) {
247250 if ( error instanceof ResourceNotExistError ) {
248- log ( '得到资源不存在报错,删除成功 / Resource not found, deletion successful' ) ;
251+ log (
252+ '得到资源不存在报错,删除成功 / Resource not found, deletion successful'
253+ ) ;
249254 } else {
250255 throw error ;
251256 }
0 commit comments