@clawlabz/clawarena 0.2.4 → 0.2.5
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/index.ts +37 -12
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare function setTimeout(fn: () => void, ms: number): unknown
|
|
|
5
5
|
declare function clearTimeout(id: unknown): void
|
|
6
6
|
declare function fetch(url: string, init?: Record<string, unknown>): Promise<{ status: number; text: () => Promise<string>; headers: Headers }>
|
|
7
7
|
|
|
8
|
-
const VERSION = '0.2.
|
|
8
|
+
const VERSION = '0.2.5'
|
|
9
9
|
const PLUGIN_ID = 'clawarena'
|
|
10
10
|
const DEFAULT_BASE_URL = 'https://arena.clawlabz.xyz'
|
|
11
11
|
const DEFAULT_HEARTBEAT_SECONDS = 20
|
|
@@ -907,20 +907,45 @@ export default function register(api: OpenClawApi) {
|
|
|
907
907
|
.command(`${prefix}:status`)
|
|
908
908
|
.description('Show runner status')
|
|
909
909
|
.action(async () => {
|
|
910
|
-
const payload = buildStatusPayload()
|
|
911
910
|
try {
|
|
912
|
-
const
|
|
913
|
-
if (
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
911
|
+
const agents = await loadAllAgents()
|
|
912
|
+
if (agents.length === 0) {
|
|
913
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: 'No agent. Run clawarena:create first.' }, null, 2)}\n`)
|
|
914
|
+
return
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
const cfg = getConfig(api)
|
|
918
|
+
const results: Record<string, unknown>[] = []
|
|
919
|
+
|
|
920
|
+
for (const agent of agents) {
|
|
921
|
+
const baseUrl = agent.baseUrl || cfg.baseUrl
|
|
922
|
+
const [meRes, runtimeRes, queueRes] = await Promise.all([
|
|
923
|
+
requestArena(baseUrl, agent.apiKey, 'GET', '/api/agents/me', { expectedStatuses: [200] }).catch(() => null),
|
|
924
|
+
requestArena(baseUrl, agent.apiKey, 'GET', '/api/agents/runtime', { expectedStatuses: [200] }).catch(() => null),
|
|
925
|
+
requestArena(baseUrl, agent.apiKey, 'GET', '/api/queue/status', { expectedStatuses: [200] }).catch(() => null),
|
|
918
926
|
])
|
|
919
|
-
|
|
920
|
-
|
|
927
|
+
|
|
928
|
+
const localRunner = runners.get(agent.agentId)
|
|
929
|
+
results.push({
|
|
930
|
+
agentId: agent.agentId,
|
|
931
|
+
name: meRes?.data?.name || agent.name,
|
|
932
|
+
rating: meRes?.data?.rating ?? null,
|
|
933
|
+
runtime: runtimeRes?.data || null,
|
|
934
|
+
queue: queueRes?.data || null,
|
|
935
|
+
localRunner: localRunner ? localRunner.status : 'not_in_this_process',
|
|
936
|
+
baseUrl,
|
|
937
|
+
})
|
|
921
938
|
}
|
|
922
|
-
|
|
923
|
-
|
|
939
|
+
|
|
940
|
+
process.stdout.write(`${JSON.stringify({
|
|
941
|
+
ok: true,
|
|
942
|
+
plugin: PLUGIN_ID,
|
|
943
|
+
version: VERSION,
|
|
944
|
+
agents: results,
|
|
945
|
+
}, null, 2)}\n`)
|
|
946
|
+
} catch (err: unknown) {
|
|
947
|
+
process.stdout.write(`status error: ${(err as Error).message}\n`)
|
|
948
|
+
}
|
|
924
949
|
})
|
|
925
950
|
}
|
|
926
951
|
|
package/openclaw.plugin.json
CHANGED