@clawlabz/clawarena 0.2.10 → 0.2.11

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 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.10'
8
+ const VERSION = '0.2.11'
9
9
  const PLUGIN_ID = 'clawarena'
10
10
  const DEFAULT_BASE_URL = 'https://arena.clawlabz.xyz'
11
11
  const DEFAULT_HEARTBEAT_SECONDS = 20
@@ -338,6 +338,7 @@ class ArenaRunner {
338
338
  private log: LogFn
339
339
  private warn: LogFn
340
340
  private subagent: SubagentApi | null
341
+ private subagentDisabled = false
341
342
 
342
343
  agentId = ''
343
344
  agentName = ''
@@ -477,7 +478,7 @@ class ArenaRunner {
477
478
  gameId: string,
478
479
  state: Record<string, unknown>,
479
480
  ): Promise<{ actions: Array<{ action: string; [k: string]: unknown }>; markSubmittedOnExhausted: boolean } | null> {
480
- if (!this.subagent) return null
481
+ if (!this.subagent || this.subagentDisabled) return null
481
482
  const llmContext = state.llmContext as { rules?: string; situation?: string; keyFacts?: Record<string, string> } | null
482
483
  const availableActions = state.availableActions as unknown[] | undefined
483
484
  if (!llmContext?.rules || !availableActions?.length) return null
@@ -568,7 +569,10 @@ Reply with ONLY a valid JSON object matching one of the available actions. No ex
568
569
  return { submitted: false, waitSeconds: w, finished: false }
569
570
  }
570
571
  if (response.status === 409) return { submitted: false, waitSeconds: 0, finished: true }
571
- if (response.status === 401 || response.status === 403) throw new Error(`action unauthorized status=${response.status}`)
572
+ if (response.status === 401 || response.status === 403) {
573
+ this.warn(`action unauthorized status=${response.status}, exiting game`)
574
+ return { submitted: false, waitSeconds: 0, finished: true }
575
+ }
572
576
 
573
577
  const code = String(response.data?.code || '')
574
578
  const errorText = String(response.data?.error || '')
@@ -616,7 +620,8 @@ Reply with ONLY a valid JSON object matching one of the available actions. No ex
616
620
  while (!this.stopRequested) {
617
621
  await this.maybeHeartbeat('in_game', gameId)
618
622
 
619
- const statePath = this.subagent ? `/api/games/${gameId}/state/private?includeLlm=true` : `/api/games/${gameId}/state/private`
623
+ const useLlm = this.subagent && !this.subagentDisabled
624
+ const statePath = useLlm ? `/api/games/${gameId}/state/private?includeLlm=true` : `/api/games/${gameId}/state/private`
620
625
  const stateResponse = await this.request('GET', statePath, { expectedStatuses: [200, 401, 403, 404] })
621
626
  if (stateResponse.status !== 200) {
622
627
  this.warn(`state/private unavailable game=${gameId} status=${stateResponse.status}`)
@@ -651,12 +656,14 @@ Reply with ONLY a valid JSON object matching one of the available actions. No ex
651
656
 
652
657
  // Try LLM first, fallback to template
653
658
  let plan: { actions: Array<{ action: string; [k: string]: unknown }>; markSubmittedOnExhausted: boolean } | null = null
654
- if (this.subagent && !forceFallback) {
659
+ if (this.subagent && !this.subagentDisabled && !forceFallback) {
655
660
  try {
656
661
  plan = await this.tryLlmAction(gameId, state)
657
662
  if (plan) this.log(`llm action: ${JSON.stringify(plan.actions[0])}`)
658
663
  } catch (err) {
659
- this.warn(`llm action failed: ${(err as Error).message}`)
664
+ const msg = (err as Error).message || ''
665
+ this.warn(`llm disabled: ${msg}`)
666
+ this.subagentDisabled = true // permanent fallback to templates
660
667
  }
661
668
  }
662
669
  if (!plan) {
@@ -2,7 +2,7 @@
2
2
  "id": "clawarena",
3
3
  "name": "ClawArena OpenClaw",
4
4
  "description": "Connect OpenClaw agents to ClawArena — auto-queue, auto-play, always online.",
5
- "version": "0.2.10",
5
+ "version": "0.2.11",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawlabz/clawarena",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Official ClawArena plugin for OpenClaw Gateway.",
5
5
  "type": "module",
6
6
  "license": "MIT",