File size: 2,403 Bytes
db75f77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const BASE = '/api'

async function request(method, path, body) {
  const opts = {
    method,
    headers: { 'Content-Type': 'application/json' },
  }
  if (body !== undefined) opts.body = JSON.stringify(body)
  const res = await fetch(`${BASE}${path}`, opts)
  if (!res.ok) {
    const err = await res.text()
    throw new Error(`${res.status} ${res.statusText}: ${err}`)
  }
  return res.json()
}

// Unwrap openenv envelope: {observation: {...}, reward, done} β†’ flat object with reward/done merged in
function unwrapObservation(envResponse) {
  if (envResponse && typeof envResponse.observation === 'object') {
    return { ...envResponse.observation, reward: envResponse.reward, done: envResponse.done }
  }
  return envResponse
}

// POST /reset β€” start a new episode (openenv wire format)
export async function resetEpisode() {
  const raw = await request('POST', '/reset', {})
  return unwrapObservation(raw)
}

// POST /step β€” advance episode with an action (openenv wire format)
// episode_id is an extra field on the StepRequest body (StepRequest has extra="allow")
export async function stepEpisode(episode_id, action) {
  const raw = await request('POST', '/step', { action, episode_id })
  return unwrapObservation(raw)
}

// GET /episode_state?episode_id= β€” inspect specific episode without advancing
export async function getState(episode_id) {
  return request('GET', `/episode_state?episode_id=${episode_id}`)
}

// GET /tasks β€” full task bank
export async function getTasks() {
  return request('GET', '/tasks')
}

// POST /grader β€” standalone offline grader
export async function runGrader(payload) {
  return request('POST', '/grader', payload)
}

// GET /baseline β€” pre-computed baseline scores
export async function getBaseline() {
  return request('GET', '/baseline')
}

// GET /forge/queue β€” active queue state
export async function getForgeQueue() {
  return request('GET', '/forge/queue')
}

// GET /forge/stats β€” aggregate Forge statistics
export async function getForgeStats() {
  return request('GET', '/forge/stats')
}

// GET /oversight/stats β€” detection/explanation/correction per domain+corruption
export async function getOversightStats() {
  return request('GET', '/oversight/stats')
}

// GET /oversight/difficulty_curve β€” pass@k time series
export async function getDifficultyCurve() {
  return request('GET', '/oversight/difficulty_curve')
}