@tangle-network/agent-bench 2.0.0 → 3.0.0

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 (215) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +24 -2
  3. package/dist/adapters.d.ts +3 -3
  4. package/dist/adapters.js +3 -5
  5. package/dist/adapters.js.map +1 -1
  6. package/dist/benchmarks/_harness.d.ts +4 -4
  7. package/dist/benchmarks/_harness.js +5 -2
  8. package/dist/benchmarks/_harness.js.map +1 -1
  9. package/dist/benchmarks/aec-bench.d.ts +2 -2
  10. package/dist/benchmarks/aec-bench.js +49 -42
  11. package/dist/benchmarks/aec-bench.js.map +1 -1
  12. package/dist/benchmarks/agentbench.d.ts +2 -2
  13. package/dist/benchmarks/agentbench.js +41 -34
  14. package/dist/benchmarks/agentbench.js.map +1 -1
  15. package/dist/benchmarks/appworld.d.ts +4 -4
  16. package/dist/benchmarks/appworld.js +67 -53
  17. package/dist/benchmarks/appworld.js.map +1 -1
  18. package/dist/benchmarks/bfcl.d.ts +2 -2
  19. package/dist/benchmarks/bfcl.js +52 -44
  20. package/dist/benchmarks/bfcl.js.map +1 -1
  21. package/dist/benchmarks/cad-design.d.ts +2 -2
  22. package/dist/benchmarks/cad-design.js +53 -44
  23. package/dist/benchmarks/cad-design.js.map +1 -1
  24. package/dist/benchmarks/cadbench.d.ts +2 -2
  25. package/dist/benchmarks/cadbench.js +1 -1
  26. package/dist/benchmarks/cadgenbench.d.ts +2 -2
  27. package/dist/benchmarks/cadgenbench.js +1 -1
  28. package/dist/benchmarks/commit0.d.ts +2 -2
  29. package/dist/benchmarks/commit0.js +38 -31
  30. package/dist/benchmarks/commit0.js.map +1 -1
  31. package/dist/benchmarks/crag.d.ts +2 -2
  32. package/dist/benchmarks/crag.js +37 -32
  33. package/dist/benchmarks/crag.js.map +1 -1
  34. package/dist/benchmarks/dabstep.d.ts +2 -2
  35. package/dist/benchmarks/dabstep.js +41 -34
  36. package/dist/benchmarks/dabstep.js.map +1 -1
  37. package/dist/benchmarks/finresearchbench.d.ts +4 -4
  38. package/dist/benchmarks/finresearchbench.js +61 -48
  39. package/dist/benchmarks/finresearchbench.js.map +1 -1
  40. package/dist/benchmarks/finsearchcomp.d.ts +3 -3
  41. package/dist/benchmarks/finsearchcomp.js +54 -43
  42. package/dist/benchmarks/finsearchcomp.js.map +1 -1
  43. package/dist/benchmarks/frames.d.ts +2 -2
  44. package/dist/benchmarks/frames.js +66 -51
  45. package/dist/benchmarks/frames.js.map +1 -1
  46. package/dist/benchmarks/hotpotqa.d.ts +2 -2
  47. package/dist/benchmarks/hotpotqa.js +59 -47
  48. package/dist/benchmarks/hotpotqa.js.map +1 -1
  49. package/dist/benchmarks/humaneval.d.ts +3 -3
  50. package/dist/benchmarks/humaneval.js +39 -35
  51. package/dist/benchmarks/humaneval.js.map +1 -1
  52. package/dist/benchmarks/mcad-bench.d.ts +2 -2
  53. package/dist/benchmarks/mcad-bench.js +68 -56
  54. package/dist/benchmarks/mcad-bench.js.map +1 -1
  55. package/dist/benchmarks/mcad-cq-bench.d.ts +2 -2
  56. package/dist/benchmarks/mcad-cq-bench.js +69 -57
  57. package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
  58. package/dist/benchmarks/mcad-cq-golds.d.ts +1 -1
  59. package/dist/benchmarks/mcad-cq-golds.js +1 -1
  60. package/dist/benchmarks/mcad-cq-golds.js.map +1 -1
  61. package/dist/benchmarks/mcad-golds.d.ts +1 -1
  62. package/dist/benchmarks/mcad-golds.js.map +1 -1
  63. package/dist/benchmarks/mind2web.d.ts +3 -3
  64. package/dist/benchmarks/mind2web.js +62 -49
  65. package/dist/benchmarks/mind2web.js.map +1 -1
  66. package/dist/benchmarks/nomiracl.d.ts +2 -2
  67. package/dist/benchmarks/nomiracl.js +43 -36
  68. package/dist/benchmarks/nomiracl.js.map +1 -1
  69. package/dist/benchmarks/open-rag-bench.d.ts +2 -2
  70. package/dist/benchmarks/open-rag-bench.js +37 -32
  71. package/dist/benchmarks/open-rag-bench.js.map +1 -1
  72. package/dist/benchmarks/programbench.d.ts +2 -2
  73. package/dist/benchmarks/programbench.js +28 -23
  74. package/dist/benchmarks/programbench.js.map +1 -1
  75. package/dist/benchmarks/rag-shared.d.ts +2 -2
  76. package/dist/benchmarks/rag-shared.js +15 -13
  77. package/dist/benchmarks/rag-shared.js.map +1 -1
  78. package/dist/benchmarks/ragbench.d.ts +2 -2
  79. package/dist/benchmarks/ragbench.js +34 -29
  80. package/dist/benchmarks/ragbench.js.map +1 -1
  81. package/dist/benchmarks/simpleqa.d.ts +2 -2
  82. package/dist/benchmarks/simpleqa.js +62 -51
  83. package/dist/benchmarks/simpleqa.js.map +1 -1
  84. package/dist/benchmarks/swe-bench.d.ts +4 -4
  85. package/dist/benchmarks/swe-bench.js +47 -41
  86. package/dist/benchmarks/swe-bench.js.map +1 -1
  87. package/dist/benchmarks/t2-ragbench.d.ts +2 -2
  88. package/dist/benchmarks/t2-ragbench.js +37 -32
  89. package/dist/benchmarks/t2-ragbench.js.map +1 -1
  90. package/dist/benchmarks/tau-bench-shared.d.ts +2 -2
  91. package/dist/benchmarks/tau-bench-shared.js +43 -36
  92. package/dist/benchmarks/tau-bench-shared.js.map +1 -1
  93. package/dist/benchmarks/tau2-bench.d.ts +2 -2
  94. package/dist/benchmarks/tau2-bench.js.map +1 -1
  95. package/dist/benchmarks/tau3-banking.d.ts +2 -2
  96. package/dist/benchmarks/tau3-banking.js.map +1 -1
  97. package/dist/benchmarks/terminal-bench.d.ts +2 -2
  98. package/dist/benchmarks/terminal-bench.js +29 -23
  99. package/dist/benchmarks/terminal-bench.js.map +1 -1
  100. package/dist/benchmarks/toollm.d.ts +2 -2
  101. package/dist/benchmarks/toollm.js +40 -34
  102. package/dist/benchmarks/toollm.js.map +1 -1
  103. package/dist/benchmarks/trata-hedge.d.ts +2 -2
  104. package/dist/benchmarks/trata-hedge.js +46 -38
  105. package/dist/benchmarks/trata-hedge.js.map +1 -1
  106. package/dist/benchmarks/types.d.ts +33 -63
  107. package/dist/benchmarks/types.js +36 -1
  108. package/dist/benchmarks/types.js.map +1 -0
  109. package/dist/benchmarks/webarena-verified.d.ts +2 -2
  110. package/dist/benchmarks/webarena-verified.js +29 -24
  111. package/dist/benchmarks/webarena-verified.js.map +1 -1
  112. package/dist/{cadbench-Byr5gO1M.js → cadbench-htzAmMaI.js} +39 -32
  113. package/dist/cadbench-htzAmMaI.js.map +1 -0
  114. package/dist/{cadgenbench-Tvk16YKT.js → cadgenbench-BLvEtnxU.js} +28 -22
  115. package/dist/cadgenbench-BLvEtnxU.js.map +1 -0
  116. package/dist/cli.d.ts +1 -0
  117. package/dist/cli.js +667 -0
  118. package/dist/cli.js.map +1 -0
  119. package/dist/index.d.ts +9 -8
  120. package/dist/index.js +61 -56
  121. package/dist/index.js.map +1 -1
  122. package/package.json +7 -4
  123. package/scripts/enterpriseops-gym-run.sh +82 -0
  124. package/scripts/grade-recorded-evidence.mjs +6 -6
  125. package/scripts/harvey-lab-judge.py +50 -0
  126. package/scripts/harvey-lab-run.sh +53 -0
  127. package/scripts/harvey-lab-sandbox.sh +21 -0
  128. package/scripts/healthbench-professional-run.sh +30 -0
  129. package/scripts/healthbench_professional_run.py +112 -0
  130. package/scripts/mlcr-run.sh +17 -0
  131. package/scripts/mlcr_run.py +133 -0
  132. package/scripts/prbench-run.sh +39 -0
  133. package/scripts/prbench_run.py +53 -0
  134. package/scripts/verify-packed-consumer.mjs +32 -27
  135. package/src/adapters.ts +5 -7
  136. package/src/benchmarks/_harness.test.mts +18 -1
  137. package/src/benchmarks/_harness.ts +12 -7
  138. package/src/benchmarks/aec-bench.test.mts +14 -14
  139. package/src/benchmarks/aec-bench.ts +62 -56
  140. package/src/benchmarks/agent-eval-contract.test.mts +38 -0
  141. package/src/benchmarks/agentbench.ts +44 -37
  142. package/src/benchmarks/appworld.test.mts +7 -7
  143. package/src/benchmarks/appworld.ts +88 -75
  144. package/src/benchmarks/bfcl.ts +60 -53
  145. package/src/benchmarks/cad-design.ts +34 -32
  146. package/src/benchmarks/cadbench.ts +34 -32
  147. package/src/benchmarks/cadgenbench.ts +30 -28
  148. package/src/benchmarks/commit0.test.mts +9 -9
  149. package/src/benchmarks/commit0.ts +50 -43
  150. package/src/benchmarks/crag.ts +45 -40
  151. package/src/benchmarks/dabstep-official.test.mts +8 -8
  152. package/src/benchmarks/dabstep.test.mts +11 -11
  153. package/src/benchmarks/dabstep.ts +47 -40
  154. package/src/benchmarks/external-adapters.test.mts +43 -44
  155. package/src/benchmarks/finresearchbench.ts +57 -47
  156. package/src/benchmarks/finsearchcomp.ts +72 -67
  157. package/src/benchmarks/frames.ts +76 -69
  158. package/src/benchmarks/hotpotqa.ts +69 -64
  159. package/src/benchmarks/humaneval.ts +37 -35
  160. package/src/benchmarks/mcad-bench.test.mts +30 -30
  161. package/src/benchmarks/mcad-bench.ts +66 -60
  162. package/src/benchmarks/mcad-cq-bench.ts +69 -63
  163. package/src/benchmarks/mcad-cq-golds.ts +1 -1
  164. package/src/benchmarks/mcad-cq.test.mts +40 -40
  165. package/src/benchmarks/mcad-golds.ts +1 -1
  166. package/src/benchmarks/mind2web.ts +66 -58
  167. package/src/benchmarks/nomiracl.ts +53 -46
  168. package/src/benchmarks/open-rag-bench.ts +47 -42
  169. package/src/benchmarks/programbench.test.mts +10 -10
  170. package/src/benchmarks/programbench.ts +38 -33
  171. package/src/benchmarks/rag-benchmarks.test.mts +31 -31
  172. package/src/benchmarks/rag-shared.ts +13 -16
  173. package/src/benchmarks/ragbench.ts +44 -39
  174. package/src/benchmarks/simpleqa.ts +78 -73
  175. package/src/benchmarks/swe-bench.test.mts +3 -3
  176. package/src/benchmarks/swe-bench.ts +66 -61
  177. package/src/benchmarks/t2-ragbench.ts +47 -42
  178. package/src/benchmarks/tau-bench-shared.ts +51 -44
  179. package/src/benchmarks/tau-pin.test.mts +1 -1
  180. package/src/benchmarks/tau2-bench.ts +2 -2
  181. package/src/benchmarks/tau3-banking.ts +2 -2
  182. package/src/benchmarks/terminal-bench.test.mts +3 -3
  183. package/src/benchmarks/terminal-bench.ts +41 -36
  184. package/src/benchmarks/toollm.ts +54 -47
  185. package/src/benchmarks/trata-hedge.ts +57 -52
  186. package/src/benchmarks/types.ts +70 -59
  187. package/src/benchmarks/webarena-verified.ts +49 -42
  188. package/src/cli.ts +74 -0
  189. package/src/corpus-replay.mts +9 -9
  190. package/src/examples/benchmark-matrix.mts +13 -10
  191. package/src/gate-cli.mts +5 -5
  192. package/src/gate.test.mts +14 -12
  193. package/src/gate.ts +23 -22
  194. package/src/index.ts +17 -11
  195. package/src/published.test.mts +534 -0
  196. package/src/published.ts +524 -0
  197. package/src/run-benchmarks-cli.mts +2 -2
  198. package/src/run-benchmarks.test.mts +58 -48
  199. package/src/run-benchmarks.ts +64 -57
  200. package/src/swe-bench-env.ts +6 -6
  201. package/src/worker.ts +1 -1
  202. package/dist/benchmarks/enterpriseops-gym.d.ts +0 -6
  203. package/dist/benchmarks/enterpriseops-gym.js +0 -236
  204. package/dist/benchmarks/enterpriseops-gym.js.map +0 -1
  205. package/dist/cadbench-Byr5gO1M.js.map +0 -1
  206. package/dist/cadgenbench-Tvk16YKT.js.map +0 -1
  207. package/fixtures/enterpriseops-gym.json +0 -103
  208. package/scripts/enterpriseops_gym_judge.py +0 -281
  209. package/src/benchmarks/enterpriseops-gym.test.mts +0 -77
  210. package/src/benchmarks/enterpriseops-gym.ts +0 -343
  211. package/src/eops-skills/address-every-subtask.md +0 -5
  212. package/src/eops-skills/exact-tools-and-args.md +0 -5
  213. package/src/eops-skills/full-sequence-to-goal.md +0 -5
  214. package/src/eops-skills/ground-every-value.md +0 -5
  215. package/src/eops-skills/honor-the-policies.md +0 -5
@@ -1,4 +1,5 @@
1
1
  import { benchRoot } from "./_harness.js";
2
+ import { runtimeBenchmark } from "./types.js";
2
3
  import { readFile } from "node:fs/promises";
3
4
  import { join } from "node:path";
4
5
  // src/benchmarks/agentbench.ts
@@ -36,22 +37,24 @@ function rowToTask(row, index, split) {
36
37
  };
37
38
  return {
38
39
  id: `dbbench-${split}-${index}`,
39
- split,
40
- prompt: [
41
- "Answer this AgentBench DBBench question using the table below.",
42
- "Return only the answer value.",
43
- "",
44
- `Question: ${row.description}`,
45
- row.table?.table_name ? `Table: ${row.table.table_name}` : void 0,
46
- columns ? `Columns: ${columns}` : void 0,
47
- sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : void 0
48
- ].filter(Boolean).join("\n"),
40
+ payload: {
41
+ subset: split,
42
+ prompt: [
43
+ "Answer this AgentBench DBBench question using the table below.",
44
+ "Return only the answer value.",
45
+ "",
46
+ `Question: ${row.description}`,
47
+ row.table?.table_name ? `Table: ${row.table.table_name}` : void 0,
48
+ columns ? `Columns: ${columns}` : void 0,
49
+ sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : void 0
50
+ ].filter(Boolean).join("\n")
51
+ },
49
52
  metadata: meta
50
53
  };
51
54
  }
52
55
  function readMeta(task) {
53
56
  const md = task.metadata;
54
- if (!md || !Array.isArray(md.labels)) throw new Error(`agentbench task ${task.id} missing metadata — loadTasks did not populate it`);
57
+ if (!md || !Array.isArray(md.labels)) throw new Error(`agentbench task ${task.id} missing metadata — loadAll did not populate it`);
55
58
  return md;
56
59
  }
57
60
  function selectRows(rows, opts, split) {
@@ -73,41 +76,45 @@ async function loadFixtures(opts, split) {
73
76
  }
74
77
  function createAgentBenchAdapter() {
75
78
  const fixturesMode = process.env.AGENTBENCH_FIXTURES === "1";
76
- return {
77
- name: "agentbench",
78
- output: agentbenchAnswerOutput,
79
- async preflight() {
80
- if (fixturesMode) return;
81
- const dir = agentbenchDir();
82
- if (!dir) throw new Error("AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.");
83
- await loadJsonl(join(dir, "data", "dbbench", `${DEFAULT_SPLIT}.jsonl`));
84
- },
85
- async loadTasks(opts = {}) {
86
- const split = opts.split ?? DEFAULT_SPLIT;
79
+ return runtimeBenchmark({
80
+ id: "agentbench",
81
+ async loadAll(opts = {}) {
82
+ const split = opts.subset ?? DEFAULT_SPLIT;
87
83
  if (fixturesMode) return loadFixtures(opts, split);
88
84
  const dir = agentbenchDir();
89
85
  if (!dir) throw new Error("AGENTBENCH_DIR is required to load AgentBench DBBench tasks");
90
86
  return selectRows(await loadJsonl(join(dir, "data", "dbbench", `${split}.jsonl`)), opts, split);
91
87
  },
92
- async goldArtifact(task) {
93
- return readMeta(task).labels[0];
94
- },
95
- async judge(task, artifact) {
88
+ async evaluate(task, artifact) {
96
89
  const meta = readMeta(task);
97
90
  const got = normalizeAnswer(artifact);
98
91
  const resolved = meta.labels.map(normalizeAnswer).includes(got);
92
+ const raw = {
93
+ subset: meta.subset,
94
+ split: meta.split,
95
+ expected: meta.labels,
96
+ got: artifact
97
+ };
99
98
  return {
100
- resolved,
99
+ passed: resolved,
101
100
  score: resolved ? 1 : 0,
102
- detail: JSON.stringify({
103
- subset: meta.subset,
104
- split: meta.split,
105
- expected: meta.labels,
106
- got: artifact
107
- })
101
+ notes: JSON.stringify(raw),
102
+ raw
108
103
  };
104
+ },
105
+ runtime: {
106
+ output: agentbenchAnswerOutput,
107
+ async preflight() {
108
+ if (fixturesMode) return;
109
+ const dir = agentbenchDir();
110
+ if (!dir) throw new Error("AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.");
111
+ await loadJsonl(join(dir, "data", "dbbench", `${DEFAULT_SPLIT}.jsonl`));
112
+ },
113
+ async goldArtifact(task) {
114
+ return readMeta(task).labels[0];
115
+ }
109
116
  }
110
- };
117
+ });
111
118
  }
112
119
  export { agentbenchAnswerOutput, createAgentBenchAdapter };
113
120
 
@@ -1 +1 @@
1
- {"version":3,"file":"agentbench.js","names":[],"sources":["../../src/benchmarks/agentbench.ts"],"sourcesContent":["/**\n * AgentBench deterministic subset adapter.\n *\n * This targets AgentBench DBBench rows only: question + table + published label.\n * It does not wrap AgentBench's controller protocol or the non-deterministic game\n * environments. Worker artifact = final answer text. Judge = exact match against\n * the official DBBench label list after light whitespace/case normalization.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'\nimport { benchRoot } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'agentbench-dbbench.json')\nconst DEFAULT_SPLIT = 'dev'\n\ninterface AgentBenchDbRow {\n description: string\n label: string[]\n table?: {\n table_name?: string\n table_info?: {\n columns?: Array<{ name: string; type?: string }>\n rows?: unknown[][]\n }\n }\n}\n\ninterface AgentBenchMeta {\n labels: string[]\n split: string\n subset: 'dbbench'\n table?: AgentBenchDbRow['table']\n}\n\nconst agentbenchDir = (): string | undefined => process.env.AGENTBENCH_DIR\n\nexport const agentbenchAnswerOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n const fences = [...text.matchAll(/```(?:text|answer)?\\s*\\n([\\s\\S]*?)```/g)]\n return (fences.at(-1)?.[1] ?? text).trim()\n },\n}\n\nfunction normalizeAnswer(value: string): string {\n return value\n .toLowerCase()\n .replace(/\\s+/g, ' ')\n .replace(/^[\"'`]+|[\"'`]+$/g, '')\n .trim()\n}\n\nfunction rowToTask(row: AgentBenchDbRow, index: number, split: string): BenchTask {\n const columns = row.table?.table_info?.columns?.map((c) => `${c.name}${c.type ? ` (${c.type})` : ''}`).join(', ')\n const sampleRows = row.table?.table_info?.rows?.slice(0, 40)\n const meta: AgentBenchMeta = {\n labels: row.label,\n split,\n subset: 'dbbench',\n table: row.table,\n }\n return {\n id: `dbbench-${split}-${index}`,\n split,\n prompt: [\n 'Answer this AgentBench DBBench question using the table below.',\n 'Return only the answer value.',\n '',\n `Question: ${row.description}`,\n row.table?.table_name ? `Table: ${row.table.table_name}` : undefined,\n columns ? `Columns: ${columns}` : undefined,\n sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : undefined,\n ]\n .filter(Boolean)\n .join('\\n'),\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): AgentBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.labels)) {\n throw new Error(`agentbench task ${task.id} missing metadata — loadTasks did not populate it`)\n }\n return md as unknown as AgentBenchMeta\n}\n\nfunction selectRows(rows: AgentBenchDbRow[], opts: LoadOptions, split: string): BenchTask[] {\n let tasks = rows.map((row, index) => rowToTask(row, index, split))\n if (opts.ids) {\n const want = new Set(opts.ids)\n tasks = tasks.filter((task) => want.has(task.id))\n } else if (opts.limit !== undefined) {\n tasks = tasks.slice(0, opts.limit)\n }\n if (tasks.length === 0) throw new Error(`AgentBench DBBench: no tasks matched ${JSON.stringify(opts)}`)\n return tasks\n}\n\nasync function loadJsonl(path: string): Promise<AgentBenchDbRow[]> {\n const raw = await readFile(path, 'utf8')\n return raw\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line) => JSON.parse(line) as AgentBenchDbRow)\n}\n\nasync function loadFixtures(opts: LoadOptions, split: string): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as AgentBenchDbRow[]\n console.warn(`[agentbench] AGENTBENCH_FIXTURES=1 — loading ${rows.length} DBBench adapter fixtures`)\n return selectRows(rows, opts, split)\n}\n\nexport function createAgentBenchAdapter(): BenchmarkAdapter {\n const fixturesMode = process.env.AGENTBENCH_FIXTURES === '1'\n\n return {\n name: 'agentbench',\n output: agentbenchAnswerOutput,\n\n async preflight() {\n if (fixturesMode) return\n const dir = agentbenchDir()\n if (!dir) {\n throw new Error('AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.')\n }\n await loadJsonl(join(dir, 'data', 'dbbench', `${DEFAULT_SPLIT}.jsonl`))\n },\n\n async loadTasks(opts: LoadOptions = {}) {\n const split = opts.split ?? DEFAULT_SPLIT\n if (fixturesMode) return loadFixtures(opts, split)\n const dir = agentbenchDir()\n if (!dir) throw new Error('AGENTBENCH_DIR is required to load AgentBench DBBench tasks')\n return selectRows(await loadJsonl(join(dir, 'data', 'dbbench', `${split}.jsonl`)), opts, split)\n },\n\n async goldArtifact(task: BenchTask) {\n return readMeta(task).labels[0]\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const got = normalizeAnswer(artifact)\n const expected = meta.labels.map(normalizeAnswer)\n const resolved = expected.includes(got)\n return {\n resolved,\n score: resolved ? 1 : 0,\n detail: JSON.stringify({ subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact }),\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,WAAW,KAAK,WAAW,YAAY,yBAAyB;AACtE,MAAM,gBAAgB;AAqBtB,MAAM,sBAA0C,QAAQ,IAAI;AAE5D,MAAa,yBAAgD,EAC3D,MAAM,QAAQ;CACZ,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,QAAQ;EACvB,MAAM,IAAK,IAA2C;EACtD,MAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;EACxC,IAAI,OAAO,MAAM,YAAY,EAAE,SAAS,GAAG,OAAO;CACpD;CAEA,QAAQ,CADQ,GAAG,KAAK,SAAS,wCAAwC,CAC5D,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,KAAA,CAAM,KAAK;AAC3C,EACF;AAEA,SAAS,gBAAgB,OAAuB;CAC9C,OAAO,MACJ,YAAY,CAAC,CACb,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,oBAAoB,EAAE,CAAC,CAC/B,KAAK;AACV;AAEA,SAAS,UAAU,KAAsB,OAAe,OAA0B;CACh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OAAO,KAAK;KAAO,UAAU,KAAK;KAAQ,KAAK;IAAS,CAAC;GACzG;EACF;CACF;AACF"}
1
+ {"version":3,"file":"agentbench.js","names":[],"sources":["../../src/benchmarks/agentbench.ts"],"sourcesContent":["/**\n * AgentBench deterministic subset adapter.\n *\n * This targets AgentBench DBBench rows only: question + table + published label.\n * It does not wrap AgentBench's controller protocol or the non-deterministic game\n * environments. Worker artifact = final answer text. Judge = exact match against\n * the official DBBench label list after light whitespace/case normalization.\n */\n\nimport { readFile } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport type { OutputAdapter } from '@tangle-network/agent-runtime/kernel'\nimport { benchRoot } from './_harness'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\nconst FIXTURES = join(benchRoot, 'fixtures', 'agentbench-dbbench.json')\nconst DEFAULT_SPLIT = 'dev'\n\ninterface AgentBenchDbRow {\n description: string\n label: string[]\n table?: {\n table_name?: string\n table_info?: {\n columns?: Array<{ name: string; type?: string }>\n rows?: unknown[][]\n }\n }\n}\n\ninterface AgentBenchMeta {\n labels: string[]\n split: string\n subset: 'dbbench'\n table?: AgentBenchDbRow['table']\n}\n\nconst agentbenchDir = (): string | undefined => process.env.AGENTBENCH_DIR\n\nexport const agentbenchAnswerOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n const fences = [...text.matchAll(/```(?:text|answer)?\\s*\\n([\\s\\S]*?)```/g)]\n return (fences.at(-1)?.[1] ?? text).trim()\n },\n}\n\nfunction normalizeAnswer(value: string): string {\n return value\n .toLowerCase()\n .replace(/\\s+/g, ' ')\n .replace(/^[\"'`]+|[\"'`]+$/g, '')\n .trim()\n}\n\nfunction rowToTask(row: AgentBenchDbRow, index: number, split: string): BenchTask {\n const columns = row.table?.table_info?.columns?.map((c) => `${c.name}${c.type ? ` (${c.type})` : ''}`).join(', ')\n const sampleRows = row.table?.table_info?.rows?.slice(0, 40)\n const meta: AgentBenchMeta = {\n labels: row.label,\n split,\n subset: 'dbbench',\n table: row.table,\n }\n return {\n id: `dbbench-${split}-${index}`,\n payload: {\n subset: split,\n prompt: [\n 'Answer this AgentBench DBBench question using the table below.',\n 'Return only the answer value.',\n '',\n `Question: ${row.description}`,\n row.table?.table_name ? `Table: ${row.table.table_name}` : undefined,\n columns ? `Columns: ${columns}` : undefined,\n sampleRows ? `Rows JSON: ${JSON.stringify(sampleRows)}` : undefined,\n ]\n .filter(Boolean)\n .join('\\n'),\n },\n metadata: meta as unknown as Record<string, unknown>,\n }\n}\n\nfunction readMeta(task: BenchTask): AgentBenchMeta {\n const md = task.metadata\n if (!md || !Array.isArray(md.labels)) {\n throw new Error(`agentbench task ${task.id} missing metadata — loadAll did not populate it`)\n }\n return md as unknown as AgentBenchMeta\n}\n\nfunction selectRows(rows: AgentBenchDbRow[], opts: LoadOptions, split: string): BenchTask[] {\n let tasks = rows.map((row, index) => rowToTask(row, index, split))\n if (opts.ids) {\n const want = new Set(opts.ids)\n tasks = tasks.filter((task) => want.has(task.id))\n } else if (opts.limit !== undefined) {\n tasks = tasks.slice(0, opts.limit)\n }\n if (tasks.length === 0) throw new Error(`AgentBench DBBench: no tasks matched ${JSON.stringify(opts)}`)\n return tasks\n}\n\nasync function loadJsonl(path: string): Promise<AgentBenchDbRow[]> {\n const raw = await readFile(path, 'utf8')\n return raw\n .split('\\n')\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line) => JSON.parse(line) as AgentBenchDbRow)\n}\n\nasync function loadFixtures(opts: LoadOptions, split: string): Promise<BenchTask[]> {\n const rows = JSON.parse(await readFile(FIXTURES, 'utf8')) as AgentBenchDbRow[]\n console.warn(`[agentbench] AGENTBENCH_FIXTURES=1 — loading ${rows.length} DBBench adapter fixtures`)\n return selectRows(rows, opts, split)\n}\n\nexport function createAgentBenchAdapter(): RuntimeBenchmark {\n const fixturesMode = process.env.AGENTBENCH_FIXTURES === '1'\n\n return runtimeBenchmark({\n id: 'agentbench',\n\n async loadAll(opts: LoadOptions = {}) {\n const split = opts.subset ?? DEFAULT_SPLIT\n if (fixturesMode) return loadFixtures(opts, split)\n const dir = agentbenchDir()\n if (!dir) throw new Error('AGENTBENCH_DIR is required to load AgentBench DBBench tasks')\n return selectRows(await loadJsonl(join(dir, 'data', 'dbbench', `${split}.jsonl`)), opts, split)\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const meta = readMeta(task)\n const got = normalizeAnswer(artifact)\n const expected = meta.labels.map(normalizeAnswer)\n const resolved = expected.includes(got)\n const raw = { subset: meta.subset, split: meta.split, expected: meta.labels, got: artifact }\n return {\n passed: resolved,\n score: resolved ? 1 : 0,\n notes: JSON.stringify(raw),\n raw,\n }\n },\n\n runtime: {\n output: agentbenchAnswerOutput,\n\n async preflight() {\n if (fixturesMode) return\n const dir = agentbenchDir()\n if (!dir) {\n throw new Error('AGENTBENCH_DIR is required. Fix: clone https://github.com/THUDM/AgentBench and set AGENTBENCH_DIR=/path/to/AgentBench.')\n }\n await loadJsonl(join(dir, 'data', 'dbbench', `${DEFAULT_SPLIT}.jsonl`))\n },\n\n async goldArtifact(task: BenchTask) {\n return readMeta(task).labels[0]\n },\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAM,WAAW,KAAK,WAAW,YAAY,yBAAyB;AACtE,MAAM,gBAAgB;AAqBtB,MAAM,sBAA0C,QAAQ,IAAI;AAE5D,MAAa,yBAAgD,EAC3D,MAAM,QAAQ;CACZ,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,QAAQ;EACvB,MAAM,IAAK,IAA2C;EACtD,MAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;EACxC,IAAI,OAAO,MAAM,YAAY,EAAE,SAAS,GAAG,OAAO;CACpD;CAEA,QAAQ,CADQ,GAAG,KAAK,SAA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AK;IAAO,UAAU,KAAK;IAAQ,KAAK;GAAS;GAC3F,OAAO;IACL,QAAQ;IACR,OAAO,WAAW,IAAI;IACtB,OAAO,KAAK,UAAU,GAAG;IACzB;GACF;EACF;EAEA,SAAS;GACP,QAAQ;GAER,MAAM,YAAY;IAChB,IAAI,cAAc;IAClB,MAAM,MAAM,cAAc;IAC1B,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,wHAAwH;IAE1I,MAAM,UAAU,KAAK,KAAK,QAAQ,WAAW,GAAG,cAAc,OAAO,CAAC;GACxE;GAEA,MAAM,aAAa,MAAiB;IAClC,OAAO,SAAS,IAAI,CAAC,CAAC,OAAO;GAC/B;EACF;CACF,CAAC;AACH"}
@@ -1,8 +1,8 @@
1
- import { BenchmarkAdapter } from "./types.js";
1
+ import { RuntimeBenchmark } from "./types.js";
2
2
  import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
3
3
  /** Worker solution code = the last fenced ```python block, else the raw text. */
4
4
  export declare const appworldSolutionOutput: OutputAdapter<string>;
5
- export declare function createAppWorldAdapter(): BenchmarkAdapter;
5
+ export declare function createAppWorldAdapter(): RuntimeBenchmark;
6
6
  /**
7
7
  * AppWorld in its NATIVE protocol, run by OUR runtime: the worker is
8
8
  * Runtime's profile-bound `router-tools` executor with one tool —
@@ -21,7 +21,7 @@ export declare function createAppWorldAdapter(): BenchmarkAdapter;
21
21
  * line 1; everything after line 1 is the steer (an analyst correction, a push
22
22
  * directive) appended to the system prompt — so the existing arms steer this
23
23
  * worker without modification. The artifact is the episode evaluation JSON
24
- * (AppWorld's evaluator ran in-world); judge() parses it, never re-executes.
24
+ * (AppWorld's evaluator ran in-world); evaluate() parses it, never re-executes.
25
25
  */
26
26
  export interface ReactResult {
27
27
  success?: boolean;
@@ -69,6 +69,6 @@ export declare function appworldToolLoopClient(cfg: {
69
69
  /** Offline-test seam; production uses Runtime's Router HTTP transport. */
70
70
  complete?: AppWorldComplete;
71
71
  }): unknown;
72
- export declare function createAppWorldReactAdapter(): BenchmarkAdapter;
72
+ export declare function createAppWorldReactAdapter(): RuntimeBenchmark;
73
73
  export {};
74
74
  //# sourceMappingURL=appworld.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { benchRoot, preflightVenvImports, runVenvScriptStdin, venvPython } from "./_harness.js";
2
+ import { runtimeBenchmark } from "./types.js";
2
3
  import { join } from "node:path";
3
4
  import { spawn } from "node:child_process";
4
5
  import { createInterface } from "node:readline";
@@ -12,16 +13,16 @@ import { collectAgentTurn, createExecutor, streamAgentTurn } from "@tangle-netwo
12
13
  * evaluator: a driver runs the solution in a fresh `AppWorld(task_id=...)` world,
13
14
  * then `world.evaluate().to_dict()` reports `success` (binary TGC), `num_tests`
14
15
  * (per-requirement total) and the `passes`/`failures` lists. Score =
15
- * passes / num_tests — GRADED; resolved = success. Fully deterministic — no LLM judge.
16
+ * passes / num_tests — GRADED; passed = success. Fully deterministic — no LLM judge.
16
17
  *
17
- * loadTasks enumerates the real task suite via `load_task_ids(split)`
18
+ * loadAll enumerates the real task suite via `load_task_ids(split)`
18
19
  * (train|dev|test_normal|test_challenge); the prompt = `world.task.instruction`.
19
20
  * The OutputAdapter is stream-only, so the worker emits its solution as a fenced
20
21
  * ```python block which the driver executes.
21
22
  *
22
23
  * Requires for a live run: the bench `.venv` with `appworld` installed + the
23
24
  * unpacked engine + downloaded data (`appworld install` ; `appworld download
24
- * data`). preflight + loadTasks + judge all fail loud with the exact step when the
25
+ * data`). preflight + loadAll + evaluate all fail loud with the exact step when the
25
26
  * engine/data is absent — never a fabricated score.
26
27
  */
27
28
  const DRIVER = join(benchRoot, "scripts", "appworld_driver.py");
@@ -45,7 +46,7 @@ const WORKER_CONTRACT = [
45
46
  ].join("\n");
46
47
  function readMeta(task) {
47
48
  const md = task.metadata;
48
- if (!md || typeof md.taskId !== "string") throw new Error(`appworld task ${task.id} missing metadata.taskId — loadTasks did not populate it`);
49
+ if (!md || typeof md.taskId !== "string") throw new Error(`appworld task ${task.id} missing metadata.taskId — loadAll did not populate it`);
49
50
  return md;
50
51
  }
51
52
  /**
@@ -68,18 +69,10 @@ async function driver(args, input = "") {
68
69
  return parsed;
69
70
  }
70
71
  function createAppWorldAdapter() {
71
- return {
72
- name: "appworld",
73
- output: appworldSolutionOutput,
74
- async preflight() {
75
- await preflightVenvImports({
76
- modules: ["appworld"],
77
- requireDocker: false,
78
- fix: "Fix: bench/.venv/bin/pip install appworld ; bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data (unpacks the engine + downloads the simulated-app data/tasks). Set APPWORLD_ROOT to the data root if not the default."
79
- });
80
- },
81
- async loadTasks(opts = {}) {
82
- const split = opts.split ?? DEFAULT_SPLIT;
72
+ return runtimeBenchmark({
73
+ id: "appworld",
74
+ async loadAll(opts = {}) {
75
+ const split = opts.subset ?? DEFAULT_SPLIT;
83
76
  const tasks = (await driver([
84
77
  "load",
85
78
  "--split",
@@ -87,19 +80,20 @@ function createAppWorldAdapter() {
87
80
  ...opts.limit !== void 0 ? ["--limit", String(opts.limit)] : [],
88
81
  ...opts.ids ? ["--ids", opts.ids.join(",")] : []
89
82
  ])).tasks ?? [];
90
- if (tasks.length === 0) throw new Error(`appworld loadTasks returned no tasks for split=${split} ${JSON.stringify(opts)}`);
83
+ if (tasks.length === 0) throw new Error(`appworld loadAll returned no tasks for split=${split} ${JSON.stringify(opts)}`);
91
84
  return tasks.map((t) => ({
92
85
  id: t.task_id,
93
- split,
94
- prompt: t.instruction + WORKER_CONTRACT,
86
+ payload: {
87
+ subset: split,
88
+ prompt: t.instruction + WORKER_CONTRACT
89
+ },
95
90
  metadata: {
96
91
  taskId: t.task_id,
97
92
  split
98
93
  }
99
94
  }));
100
95
  },
101
- async goldArtifact() {},
102
- async judge(task, artifact) {
96
+ async evaluate(task, artifact) {
103
97
  const meta = readMeta(task);
104
98
  const out = await driver([
105
99
  "evaluate",
@@ -113,20 +107,33 @@ function createAppWorldAdapter() {
113
107
  const total = out.num_tests ?? passes + fails;
114
108
  const score = total > 0 ? passes / total : 0;
115
109
  const failures = Array.isArray(out.failure_names) ? out.failure_names : [];
110
+ const raw = {
111
+ taskId: meta.taskId,
112
+ success: out.success,
113
+ passes,
114
+ fails,
115
+ total,
116
+ ...failures.length ? { failures } : {}
117
+ };
116
118
  return {
117
- resolved: out.success === true,
119
+ passed: out.success === true,
118
120
  score,
119
- detail: JSON.stringify({
120
- taskId: meta.taskId,
121
- success: out.success,
122
- passes,
123
- fails,
124
- total,
125
- ...failures.length ? { failures } : {}
126
- })
121
+ notes: JSON.stringify(raw),
122
+ raw
127
123
  };
124
+ },
125
+ runtime: {
126
+ output: appworldSolutionOutput,
127
+ async preflight() {
128
+ await preflightVenvImports({
129
+ modules: ["appworld"],
130
+ requireDocker: false,
131
+ fix: "Fix: bench/.venv/bin/pip install appworld ; bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data (unpacks the engine + downloads the simulated-app data/tasks). Set APPWORLD_ROOT to the data root if not the default."
132
+ });
133
+ },
134
+ async goldArtifact() {}
128
135
  }
129
- };
136
+ });
130
137
  }
131
138
  /** Preserve a completed scientific/task result even when one accounting dimension is incomplete.
132
139
  * Unknown usage fields stay absent; later comparison/reporting can refuse a cost claim without
@@ -341,21 +348,21 @@ const reactEpisodeOutput = { parse(events) {
341
348
  } };
342
349
  function createAppWorldReactAdapter() {
343
350
  const base = createAppWorldAdapter();
344
- return {
345
- name: "appworld-react",
346
- output: reactEpisodeOutput,
347
- preflight: () => base.preflight(),
348
- async loadTasks(opts = {}) {
349
- return (await base.loadTasks(opts)).map((t) => {
351
+ return runtimeBenchmark({
352
+ id: "appworld-react",
353
+ async loadAll(opts = {}) {
354
+ return (await base.loadAll(opts)).map((t) => {
350
355
  const meta = readMeta(t);
351
356
  return {
352
357
  ...t,
353
- prompt: `@appworld-react ${meta.taskId} ${meta.split}\n`
358
+ payload: {
359
+ ...t.payload,
360
+ prompt: `@appworld-react ${meta.taskId} ${meta.split}\n`
361
+ }
354
362
  };
355
363
  });
356
364
  },
357
- goldArtifact: () => Promise.resolve(void 0),
358
- async judge(task, artifact) {
365
+ async evaluate(task, artifact) {
359
366
  const meta = readMeta(task);
360
367
  let out;
361
368
  try {
@@ -367,23 +374,30 @@ function createAppWorldReactAdapter() {
367
374
  const passes = out.passes ?? 0;
368
375
  const total = out.num_tests;
369
376
  const failures = Array.isArray(out.failure_names) ? out.failure_names : [];
377
+ const raw = {
378
+ taskId: meta.taskId,
379
+ success: out.success,
380
+ passes,
381
+ fails: out.fails ?? 0,
382
+ total,
383
+ turns: out.turns,
384
+ ...failures.length ? { failures } : {},
385
+ ...out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}
386
+ };
370
387
  return {
371
- resolved: out.success === true,
388
+ passed: out.success === true,
372
389
  score: total > 0 ? passes / total : 0,
373
- detail: JSON.stringify({
374
- taskId: meta.taskId,
375
- success: out.success,
376
- passes,
377
- fails: out.fails ?? 0,
378
- total,
379
- turns: out.turns,
380
- ...failures.length ? { failures } : {},
381
- ...out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}
382
- })
390
+ notes: JSON.stringify(raw),
391
+ raw
383
392
  };
384
393
  },
385
- leafClient: (c) => appworldToolLoopClient(c)
386
- };
394
+ runtime: {
395
+ output: reactEpisodeOutput,
396
+ preflight: async () => base.runtime.preflight?.(),
397
+ goldArtifact: () => Promise.resolve(void 0),
398
+ worker: (c) => appworldToolLoopClient(c)
399
+ }
400
+ });
387
401
  }
388
402
  export { appworldReactResultWithUsage, appworldReactUsageEvent, appworldSolutionOutput, appworldToolLoopClient, createAppWorldAdapter, createAppWorldReactAdapter };
389
403
 
@@ -1 +1 @@
1
- {"version":3,"file":"appworld.js","names":[],"sources":["../../src/benchmarks/appworld.ts"],"sourcesContent":["/**\n * AppWorld adapter (StonyBrookNLP/appworld). Worker artifact = the agent's\n * Python solution that calls the simulated apps' APIs (the same `apis.<app>.<fn>`\n * surface AppWorld exposes inside `world.execute(...)`), ending in\n * `apis.supervisor.complete_task()`. Judge = AppWorld's OWN programmatic\n * evaluator: a driver runs the solution in a fresh `AppWorld(task_id=...)` world,\n * then `world.evaluate().to_dict()` reports `success` (binary TGC), `num_tests`\n * (per-requirement total) and the `passes`/`failures` lists. Score =\n * passes / num_tests — GRADED; resolved = success. Fully deterministic — no LLM judge.\n *\n * loadTasks enumerates the real task suite via `load_task_ids(split)`\n * (train|dev|test_normal|test_challenge); the prompt = `world.task.instruction`.\n * The OutputAdapter is stream-only, so the worker emits its solution as a fenced\n * ```python block which the driver executes.\n *\n * Requires for a live run: the bench `.venv` with `appworld` installed + the\n * unpacked engine + downloaded data (`appworld install` ; `appworld download\n * data`). preflight + loadTasks + judge all fail loud with the exact step when the\n * engine/data is absent — never a fabricated score.\n */\n\nimport { spawn } from 'node:child_process'\nimport { join } from 'node:path'\nimport { createInterface } from 'node:readline'\nimport {\n collectAgentTurn,\n createExecutor,\n type OutputAdapter,\n streamAgentTurn,\n type ToolSpec,\n} from '@tangle-network/agent-runtime/kernel'\nimport { benchRoot, preflightVenvImports, runVenvScriptStdin, venvPython } from './_harness'\nimport type { BenchmarkAdapter, BenchScore, BenchTask, LoadOptions } from './types'\n\nconst DRIVER = join(benchRoot, 'scripts', 'appworld_driver.py')\n\n/** AppWorld splits; only the test splits ship evaluation-only (no setup/solution). */\nconst DEFAULT_SPLIT = 'test_normal'\n\ninterface AppWorldMeta {\n taskId: string\n split: string\n}\n\n/** Worker solution code = the last fenced ```python block, else the raw text. */\nexport const appworldSolutionOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n const fences = [...text.matchAll(/```(?:python|py)?\\s*\\n([\\s\\S]*?)```/g)]\n return (fences.at(-1)?.[1] ?? text).trim()\n },\n}\n\nconst WORKER_CONTRACT = [\n '',\n 'Solve this by writing Python that calls the available app APIs (the `apis.<app>.<function>(...)` surface). You may inspect API docs with `apis.api_docs.show_api_descriptions(app_name=...)` and `apis.api_docs.show_api_doc(app_name=..., api_name=...)`.',\n 'Authenticate where needed via the supervisor-provided credentials, perform every step the task requires, and FINISH with `apis.supervisor.complete_task()`.',\n 'Emit your COMPLETE solution as the LAST thing in your reply, in a single fenced ```python block. Nothing after the closing fence.',\n].join('\\n')\n\nfunction readMeta(task: BenchTask): AppWorldMeta {\n const md = task.metadata\n if (!md || typeof md.taskId !== 'string') {\n throw new Error(`appworld task ${task.id} missing metadata.taskId — loadTasks did not populate it`)\n }\n return md as unknown as AppWorldMeta\n}\n\n/**\n * Run the appworld engine driver with a subcommand; JSON on the LAST stdout line.\n * The solution code (evaluate) is piped to stdin via the shared stdin-aware runner —\n * execFile's `input` option is not honored async and hangs the driver's\n * sys.stdin.read() forever. `load` ignores stdin, so an empty pipe is harmless.\n */\nasync function driver(args: string[], input = ''): Promise<unknown> {\n let stdout: string\n try {\n stdout = await runVenvScriptStdin(DRIVER, args, input, { cwd: benchRoot })\n } catch (err) {\n const e = err as { message?: string }\n throw new Error(`appworld driver failed (${args.join(' ')}): ${(e.message || String(err)).slice(0, 1500)}`)\n }\n const last = stdout.trim().split('\\n').at(-1) ?? '{}'\n const parsed = JSON.parse(last) as { error?: string }\n if (parsed.error) throw new Error(`appworld driver error: ${parsed.error}`)\n return parsed\n}\n\nexport function createAppWorldAdapter(): BenchmarkAdapter {\n return {\n name: 'appworld',\n output: appworldSolutionOutput,\n\n async preflight() {\n await preflightVenvImports({\n modules: ['appworld'],\n requireDocker: false,\n fix:\n 'Fix: bench/.venv/bin/pip install appworld ; ' +\n 'bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data ' +\n '(unpacks the engine + downloads the simulated-app data/tasks). ' +\n 'Set APPWORLD_ROOT to the data root if not the default.',\n })\n },\n\n async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {\n const split = opts.split ?? DEFAULT_SPLIT\n const out = (await driver([\n 'load',\n '--split', split,\n ...(opts.limit !== undefined ? ['--limit', String(opts.limit)] : []),\n ...(opts.ids ? ['--ids', opts.ids.join(',')] : []),\n ])) as { tasks?: Array<{ task_id: string; instruction: string }> }\n const tasks = out.tasks ?? []\n if (tasks.length === 0) {\n throw new Error(`appworld loadTasks returned no tasks for split=${split} ${JSON.stringify(opts)}`)\n }\n return tasks.map(\n (t): BenchTask => ({\n id: t.task_id,\n split,\n prompt: t.instruction + WORKER_CONTRACT,\n metadata: { taskId: t.task_id, split } as unknown as Record<string, unknown>,\n }),\n )\n },\n\n async goldArtifact() {\n // Reference solution code ships only for train/dev, and only inside the\n // engine's decrypted `.bundle` (it is not a portable string this adapter can\n // emit across splits). The test splits are evaluation-only. So verify-judge\n // here requires a real solve on a train/dev task through the live engine\n // rather than a synthetic gold — returning a fabricated artifact would be a\n // fake. Returns undefined.\n return undefined\n },\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n const out = (await driver(['evaluate', '--task-id', meta.taskId, '--split', meta.split], artifact)) as {\n success?: boolean\n passes?: number\n fails?: number\n num_tests?: number\n failure_names?: string[]\n }\n const passes = out.passes ?? 0\n const fails = out.fails ?? 0\n // num_tests is the evaluator's authoritative per-requirement count; prefer it\n // over passes+fails (which can disagree if a requirement neither passed nor\n // failed). Never default the total to a phantom denominator.\n const total = out.num_tests ?? passes + fails\n const score = total > 0 ? passes / total : 0\n // failure_names = WHICH sub-tests failed — the evidence a trace analyst\n // steers on. Carried in `detail` so it reaches the verdict's `notes`.\n const failures = Array.isArray(out.failure_names) ? out.failure_names : []\n return {\n resolved: out.success === true,\n score,\n detail: JSON.stringify({\n taskId: meta.taskId,\n success: out.success,\n passes,\n fails,\n total,\n ...(failures.length ? { failures } : {}),\n }),\n }\n },\n }\n}\n\n/**\n * AppWorld in its NATIVE protocol, run by OUR runtime: the worker is\n * Runtime's profile-bound `router-tools` executor with one tool —\n * `execute_python` — bound to a persistent AppWorld world session. The driver's\n * `session` subcommand is a dumb world shim (stdin JSONL: execute → output,\n * evaluate → verdict); every inference turn, the metering, and the typed\n * toolTrace the analyst steers on belong to the runtime, so runtime\n * improvements are what this benchmark measures.\n *\n * The one-shot codegen adapter above plays a strictly harder game (no execution\n * feedback — the first wrong API call kills the whole program at judge time),\n * which flatlines the score against ANY steering; this mode is what the\n * benchmark's published baselines use, where behavior can move sub-tests.\n *\n * Protocol: the round task string is `@appworld-react <taskId> <split>` on\n * line 1; everything after line 1 is the steer (an analyst correction, a push\n * directive) appended to the system prompt — so the existing arms steer this\n * worker without modification. The artifact is the episode evaluation JSON\n * (AppWorld's evaluator ran in-world); judge() parses it, never re-executes.\n */\n\nexport interface ReactResult {\n success?: boolean\n passes?: number\n fails?: number\n num_tests?: number\n failure_names?: string[]\n turns?: number\n input_tokens?: number\n output_tokens?: number\n cost_usd?: number\n transcript?: string\n}\n\ninterface ReactRuntimeUsage {\n input: number\n output: number\n costUsd?: number\n tokensKnown?: boolean\n usdKnown?: boolean\n}\n\n/** Preserve a completed scientific/task result even when one accounting dimension is incomplete.\n * Unknown usage fields stay absent; later comparison/reporting can refuse a cost claim without\n * discarding the episode's task evidence. */\nexport function appworldReactResultWithUsage(\n verdict: ReactResult,\n usage: ReactRuntimeUsage,\n turns: number | undefined,\n transcript: string,\n): ReactResult {\n return {\n ...verdict,\n ...(turns !== undefined ? { turns } : {}),\n ...(usage.tokensKnown === false\n ? {}\n : { input_tokens: usage.input, output_tokens: usage.output }),\n ...(usage.usdKnown === false || usage.costUsd === undefined\n ? {}\n : { cost_usd: usage.costUsd }),\n transcript,\n }\n}\n\n/** Emit only usage the Runtime actually knows. Catalog estimates never become observed dollars. */\nexport function appworldReactUsageEvent(\n result: ReactResult,\n model: string,\n): { type: 'llm_call'; data: Record<string, unknown> } | undefined {\n const hasTokens =\n typeof result.input_tokens === 'number' && typeof result.output_tokens === 'number'\n const hasCost = typeof result.cost_usd === 'number'\n if (!hasTokens && !hasCost) return undefined\n return {\n type: 'llm_call',\n data: {\n model,\n ...(hasTokens\n ? { tokensIn: result.input_tokens, tokensOut: result.output_tokens }\n : {}),\n ...(hasCost ? { costUsd: result.cost_usd } : {}),\n },\n }\n}\n\nconst REACT_HEADER = /^@appworld-react (\\S+) (\\S+)\\n?/\n\nconst SESSION_SYSTEM = [\n 'You are completing a task in AppWorld, a simulated multi-app environment.',\n 'Use the execute_python tool to run Python that calls the app APIs (the `apis.<app>.<function>(...)` surface).',\n 'Inspect API docs with `apis.api_docs.show_api_descriptions(app_name=...)` and `apis.api_docs.show_api_doc(app_name=..., api_name=...)`.',\n 'Authenticate where needed via the supervisor-provided credentials (`apis.supervisor.show_account_passwords()`).',\n 'Work incrementally: small snippets, read each output, correct course.',\n 'When every step of the task is done, run `apis.supervisor.complete_task()` and then reply WITHOUT calling the tool again.',\n].join('\\n')\n\nconst EXECUTE_TOOL: ToolSpec = {\n type: 'function',\n function: {\n name: 'execute_python',\n description:\n 'Execute a Python snippet in the persistent AppWorld world. State persists across calls. Returns the execution output (API results or errors).',\n parameters: {\n type: 'object',\n properties: { code: { type: 'string', description: 'Python code calling apis.<app>.<fn>(...)' } },\n required: ['code'],\n },\n },\n}\n\n/** One persistent world session: line-JSONL request/response over the driver. */\nasync function withWorldSession<T>(\n taskId: string,\n split: string,\n signal: AbortSignal,\n fn: (call: (cmd: Record<string, unknown>) => Promise<Record<string, unknown>>, instruction: string) => Promise<T>,\n): Promise<T> {\n signal.throwIfAborted()\n const child = spawn(venvPython, [DRIVER, 'session', '--task-id', taskId, '--split', split], {\n cwd: benchRoot,\n })\n const stopChild = (): void => {\n if (!child.killed) child.kill('SIGTERM')\n }\n signal.addEventListener('abort', stopChild, { once: true })\n const rl = createInterface({ input: child.stdout })\n const pending: Array<(line: string) => void> = []\n const backlog: string[] = []\n rl.on('line', (l) => {\n const next = pending.shift()\n if (next) next(l)\n else backlog.push(l)\n })\n let stderr = ''\n child.stderr.on('data', (c: Buffer) => {\n stderr += c.toString('utf8')\n })\n const nextLine = (timeoutMs: number): Promise<string> =>\n new Promise((resolve, reject) => {\n if (signal.aborted) {\n reject(signal.reason)\n return\n }\n const fromBacklog = backlog.shift()\n if (fromBacklog !== undefined) return resolve(fromBacklog)\n const t = setTimeout(\n () => reject(new Error(`appworld session: no response in ${timeoutMs}ms; stderr: ${stderr.slice(-400)}`)),\n timeoutMs,\n )\n // One exit listener per await leaks (25-turn episodes blow the listener\n // cap) — remove it on the resolve path.\n const onExit = (code: number | null): void => {\n clearTimeout(t)\n signal.removeEventListener('abort', onAbort)\n reject(\n signal.aborted\n ? signal.reason\n : new Error(`appworld session exited (${code}); stderr: ${stderr.slice(-400)}`),\n )\n }\n const onAbort = (): void => {\n clearTimeout(t)\n child.removeListener('exit', onExit)\n const index = pending.indexOf(onLine)\n if (index >= 0) pending.splice(index, 1)\n reject(signal.reason)\n }\n const onLine = (line: string): void => {\n clearTimeout(t)\n child.removeListener('exit', onExit)\n signal.removeEventListener('abort', onAbort)\n resolve(line)\n }\n pending.push(onLine)\n child.once('exit', onExit)\n signal.addEventListener('abort', onAbort, { once: true })\n })\n try {\n const ready = JSON.parse(await nextLine(120_000)) as { ready?: boolean; instruction?: string; error?: string }\n if (!ready.ready) throw new Error(`appworld session failed to start: ${ready.error ?? 'no ready line'}`)\n const call = async (cmd: Record<string, unknown>): Promise<Record<string, unknown>> => {\n child.stdin.write(`${JSON.stringify(cmd)}\\n`)\n const res = JSON.parse(await nextLine(180_000)) as Record<string, unknown>\n if (typeof res.error === 'string') throw new Error(`appworld session op failed: ${res.error}`)\n return res\n }\n return await fn(call, ready.instruction ?? '')\n } finally {\n signal.removeEventListener('abort', stopChild)\n child.stdin.end()\n stopChild()\n }\n}\n\ntype AppWorldWorldSession = typeof withWorldSession\ntype AppWorldComplete = (\n body: Record<string, unknown>,\n request?: {\n readonly headers: Readonly<Record<string, string>>\n readonly signal?: AbortSignal\n },\n) => Promise<unknown>\n\n/** SandboxClient whose leaf is Runtime's profile-bound Router executor driving a world session. */\nexport function appworldToolLoopClient(cfg: {\n model: string\n routerBaseUrl: string\n routerKey: string\n maxTurns?: number\n /** Offline-test seam; production always uses the Python AppWorld session above. */\n runWorldSession?: AppWorldWorldSession\n /** Offline-test seam; production uses Runtime's Router HTTP transport. */\n complete?: AppWorldComplete\n}): unknown {\n const maxTurns = cfg.maxTurns ?? Number(process.env.REACT_MAX_TURNS ?? 40)\n const runWorldSession = cfg.runWorldSession ?? withWorldSession\n let seq = 0\n return {\n async create() {\n const id = `appworld-toolloop-${seq++}`\n return {\n id,\n async *streamPrompt(prompt: string, promptOpts?: { signal?: AbortSignal }) {\n const signal = promptOpts?.signal ?? new AbortController().signal\n signal.throwIfAborted()\n const m = prompt.match(REACT_HEADER)\n if (!m) {\n throw new Error(\n `appworld-react leaf: prompt missing '@appworld-react <taskId> <split>' header — got: ${prompt.slice(0, 120)}`,\n )\n }\n const [, taskId, split] = m\n const directive = prompt.replace(REACT_HEADER, '').trim()\n const out = await runWorldSession(taskId as string, split as string, signal, async (call, instruction) => {\n const system = directive ? `${SESSION_SYSTEM}\\n\\n${directive}` : SESSION_SYSTEM\n const transcriptSteps: Array<{ args: string; result: string }> = []\n const profile = {\n name: 'appworld-react-worker',\n harness: 'cli-base' as const,\n model: {\n provider: 'tangle-router',\n default: cfg.model,\n metadata: { maxTurns },\n },\n prompt: { systemPrompt: system },\n tools: { execute_python: true },\n }\n const factory = createExecutor({\n backend: 'router-tools',\n routerBaseUrl: cfg.routerBaseUrl,\n routerKey: cfg.routerKey,\n ...(cfg.complete ? { complete: cfg.complete } : {}),\n tools: [EXECUTE_TOOL],\n executeToolCall: async (name, args) => {\n if (name !== 'execute_python') return `error: unknown tool ${name}`\n const res = await call({ op: 'execute', code: String(args.code ?? '') })\n const done = res.task_completed === true\n const result = `${String(res.output ?? '')}${done ? '\\n\\n[TASK MARKED COMPLETE — reply with a final summary and do not call the tool again]' : ''}`\n transcriptSteps.push({ args: JSON.stringify(args), result })\n return result\n },\n })\n const loop = await collectAgentTurn(\n streamAgentTurn(\n { kind: 'executor', factory, profile },\n { prompt: `Task: ${instruction}` },\n { signal },\n ),\n )\n if (loop.status !== 'completed') {\n throw new Error(loop.error?.message ?? `AppWorld turn ended with ${loop.status}`)\n }\n const verdict = (await call({ op: 'evaluate' })) as unknown as ReactResult\n const transcript = transcriptSteps\n .slice(-3)\n .map((t) => `CODE:\\n${t.args.slice(0, 600)}\\nOUTPUT:\\n${t.result.slice(0, 600)}`)\n .join('\\n---\\n')\n .slice(0, 1600)\n const finalEvent = loop.events.at(-1)\n const resultMetadata =\n finalEvent?.type === 'final' && finalEvent.metadata?.result\n ? (finalEvent.metadata.result as { spent?: { iterations?: number } })\n : undefined\n return appworldReactResultWithUsage(\n verdict,\n loop.usage,\n resultMetadata?.spent?.iterations,\n transcript,\n )\n })\n const usageEvent = appworldReactUsageEvent(out, cfg.model)\n if (usageEvent) yield usageEvent\n yield { type: 'result', data: { finalText: JSON.stringify(out) } }\n },\n async delete() {},\n }\n },\n }\n}\n\n/** Artifact = the episode's evaluation JSON, verbatim (no fence extraction). */\nconst reactEpisodeOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText\n if (typeof t === 'string' && t.length > 0) text = t\n }\n return text\n },\n}\n\nexport function createAppWorldReactAdapter(): BenchmarkAdapter {\n const base = createAppWorldAdapter()\n return {\n name: 'appworld-react',\n output: reactEpisodeOutput,\n preflight: () => base.preflight(),\n\n async loadTasks(opts: LoadOptions = {}): Promise<BenchTask[]> {\n const tasks = await base.loadTasks(opts)\n return tasks.map((t) => {\n const meta = readMeta(t)\n return {\n ...t,\n // Header carries task identity to the leaf; the body (empty at round 0)\n // is the directive slot the arms append their steer into.\n prompt: `@appworld-react ${meta.taskId} ${meta.split}\\n`,\n }\n })\n },\n\n goldArtifact: () => Promise.resolve(undefined),\n\n async judge(task: BenchTask, artifact: string): Promise<BenchScore> {\n const meta = readMeta(task)\n let out: ReactResult\n try {\n out = JSON.parse(artifact) as ReactResult\n } catch {\n throw new Error(\n `appworld-react judge: artifact is not the episode's evaluation JSON (task ${meta.taskId}): ${artifact.slice(0, 200)}`,\n )\n }\n if (typeof out.success !== 'boolean' || typeof out.num_tests !== 'number') {\n throw new Error(\n `appworld-react judge: episode JSON missing success/num_tests (task ${meta.taskId}): ${artifact.slice(0, 200)}`,\n )\n }\n const passes = out.passes ?? 0\n const total = out.num_tests\n const failures = Array.isArray(out.failure_names) ? out.failure_names : []\n return {\n resolved: out.success === true,\n score: total > 0 ? passes / total : 0,\n detail: JSON.stringify({\n taskId: meta.taskId,\n success: out.success,\n passes,\n fails: out.fails ?? 0,\n total,\n turns: out.turns,\n ...(failures.length ? { failures } : {}),\n ...(out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}),\n }),\n }\n },\n\n leafClient: (c) => appworldToolLoopClient(c),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAS,KAAK,WAAW,WAAW,oBAAoB;;AAG9D,MAAM,gBAAgB;;AAQtB,MAAa,yBAAgD,EAC3D,MAAM,QAAQ;CACZ,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,QAAQ;EACvB,MAAM,IAAK,IAA2C;EACtD,MAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;EACxC,IAAI,OAAO,MAAM,YAAY,EAAE,SAAS,GAAG,OAAO;CACpD;CAEA,QAAQ,CADQ,GAAG,KAAK,SAAS,sCAAsC,CAC1D,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,KAAA,CAAM,KAAK;AAC3C,EACF;AAEA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAS,SAAS,MAA+B;CAC/C,MAAM,KAAK,KAAK;CAChB,IAAI,CAAC,MAAM,OAAO,GAAG,WAAW,UAC9B,MAAM,IAAI,MAAM,iBAAiB,KAAK,GAAG,yDAAyD;CAEpG,OAAO;AACT;;;;;;;AAQA,eAAe,O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AO,MADa,KAAK,UAAU,IAAI,EAAA,CAC1B,KAAK,MAAM;IACtB,MAAM,OAAO,SAAS,CAAC;IACvB,OAAO;KACL,GAAG;KAGH,QAAQ,mBAAmB,KAAK,OAAO,GAAG,KAAK,MAAM;IACvD;GACF,CAAC;EACH;EAEA,oBAAoB,QAAQ,QAAQ,KAAA,CAAS;EAE7C,MAAM,MAAM,MAAiB,UAAuC;GAClE,MAAM,OAAO,SAAS,IAAI;GAC1B,IAAI;GACJ,IAAI;IACF,MAAM,KAAK,MAAM,QAAQ;GAC3B,QAAQ;IACN,MAAM,IAAI,MACR,6EAA6E,KAAK,OAAO,KAAK,SAAS,MAAM,GAAG,GAAG,GACrH;GACF;GACA,IAAI,OAAO,IAAI,YAAY,aAAa,OAAO,IAAI,cAAc,UAC/D,MAAM,IAAI,MACR,sEAAsE,KAAK,OAAO,KAAK,SAAS,MAAM,GAAG,GAAG,GAC9G;GAEF,MAAM,SAAS,IAAI,UAAU;GAC7B,MAAM,QAAQ,IAAI;GAClB,MAAM,WAAW,MAAM,QAAQ,IAAI,aAAa,IAAI,IAAI,gBAAgB,CAAC;GACzE,OAAO;IACL,UAAU,IAAI,YAAY;IAC1B,OAAO,QAAQ,IAAI,SAAS,QAAQ;IACpC,QAAQ,KAAK,UAAU;KACrB,QAAQ,KAAK;KACb,SAAS,IAAI;KACb;KACA,OAAO,IAAI,SAAS;KACpB;KACA,OAAO,IAAI;KACX,GAAI,SAAS,SAAS,EAAE,SAAS,IAAI,CAAC;KACtC,GAAI,IAAI,aAAa,EAAE,gBAAgB,IAAI,WAAW,MAAM,IAAI,EAAE,IAAI,CAAC;IACzE,CAAC;GACH;EACF;EAEA,aAAa,MAAM,uBAAuB,CAAC;CAC7C;AACF"}
1
+ {"version":3,"file":"appworld.js","names":[],"sources":["../../src/benchmarks/appworld.ts"],"sourcesContent":["/**\n * AppWorld adapter (StonyBrookNLP/appworld). Worker artifact = the agent's\n * Python solution that calls the simulated apps' APIs (the same `apis.<app>.<fn>`\n * surface AppWorld exposes inside `world.execute(...)`), ending in\n * `apis.supervisor.complete_task()`. Judge = AppWorld's OWN programmatic\n * evaluator: a driver runs the solution in a fresh `AppWorld(task_id=...)` world,\n * then `world.evaluate().to_dict()` reports `success` (binary TGC), `num_tests`\n * (per-requirement total) and the `passes`/`failures` lists. Score =\n * passes / num_tests — GRADED; passed = success. Fully deterministic — no LLM judge.\n *\n * loadAll enumerates the real task suite via `load_task_ids(split)`\n * (train|dev|test_normal|test_challenge); the prompt = `world.task.instruction`.\n * The OutputAdapter is stream-only, so the worker emits its solution as a fenced\n * ```python block which the driver executes.\n *\n * Requires for a live run: the bench `.venv` with `appworld` installed + the\n * unpacked engine + downloaded data (`appworld install` ; `appworld download\n * data`). preflight + loadAll + evaluate all fail loud with the exact step when the\n * engine/data is absent — never a fabricated score.\n */\n\nimport { spawn } from 'node:child_process'\nimport { join } from 'node:path'\nimport { createInterface } from 'node:readline'\nimport {\n collectAgentTurn,\n createExecutor,\n type OutputAdapter,\n streamAgentTurn,\n type ToolSpec,\n} from '@tangle-network/agent-runtime/kernel'\nimport { benchRoot, preflightVenvImports, runVenvScriptStdin, venvPython } from './_harness'\nimport { type BenchEvaluation, type BenchTask, type LoadOptions, type RuntimeBenchmark, runtimeBenchmark } from './types'\n\nconst DRIVER = join(benchRoot, 'scripts', 'appworld_driver.py')\n\n/** AppWorld splits; only the test splits ship evaluation-only (no setup/solution). */\nconst DEFAULT_SPLIT = 'test_normal'\n\ninterface AppWorldMeta {\n taskId: string\n split: string\n}\n\n/** Worker solution code = the last fenced ```python block, else the raw text. */\nexport const appworldSolutionOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText ?? d?.text ?? d?.result\n if (typeof t === 'string' && t.length > 0) text = t\n }\n const fences = [...text.matchAll(/```(?:python|py)?\\s*\\n([\\s\\S]*?)```/g)]\n return (fences.at(-1)?.[1] ?? text).trim()\n },\n}\n\nconst WORKER_CONTRACT = [\n '',\n 'Solve this by writing Python that calls the available app APIs (the `apis.<app>.<function>(...)` surface). You may inspect API docs with `apis.api_docs.show_api_descriptions(app_name=...)` and `apis.api_docs.show_api_doc(app_name=..., api_name=...)`.',\n 'Authenticate where needed via the supervisor-provided credentials, perform every step the task requires, and FINISH with `apis.supervisor.complete_task()`.',\n 'Emit your COMPLETE solution as the LAST thing in your reply, in a single fenced ```python block. Nothing after the closing fence.',\n].join('\\n')\n\nfunction readMeta(task: BenchTask): AppWorldMeta {\n const md = task.metadata\n if (!md || typeof md.taskId !== 'string') {\n throw new Error(`appworld task ${task.id} missing metadata.taskId — loadAll did not populate it`)\n }\n return md as unknown as AppWorldMeta\n}\n\n/**\n * Run the appworld engine driver with a subcommand; JSON on the LAST stdout line.\n * The solution code (evaluate) is piped to stdin via the shared stdin-aware runner —\n * execFile's `input` option is not honored async and hangs the driver's\n * sys.stdin.read() forever. `load` ignores stdin, so an empty pipe is harmless.\n */\nasync function driver(args: string[], input = ''): Promise<unknown> {\n let stdout: string\n try {\n stdout = await runVenvScriptStdin(DRIVER, args, input, { cwd: benchRoot })\n } catch (err) {\n const e = err as { message?: string }\n throw new Error(`appworld driver failed (${args.join(' ')}): ${(e.message || String(err)).slice(0, 1500)}`)\n }\n const last = stdout.trim().split('\\n').at(-1) ?? '{}'\n const parsed = JSON.parse(last) as { error?: string }\n if (parsed.error) throw new Error(`appworld driver error: ${parsed.error}`)\n return parsed\n}\n\nexport function createAppWorldAdapter(): RuntimeBenchmark {\n return runtimeBenchmark({\n id: 'appworld',\n\n async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {\n const split = opts.subset ?? DEFAULT_SPLIT\n const out = (await driver([\n 'load',\n '--split', split,\n ...(opts.limit !== undefined ? ['--limit', String(opts.limit)] : []),\n ...(opts.ids ? ['--ids', opts.ids.join(',')] : []),\n ])) as { tasks?: Array<{ task_id: string; instruction: string }> }\n const tasks = out.tasks ?? []\n if (tasks.length === 0) {\n throw new Error(`appworld loadAll returned no tasks for split=${split} ${JSON.stringify(opts)}`)\n }\n return tasks.map(\n (t): BenchTask => ({\n id: t.task_id,\n payload: {\n subset: split,\n prompt: t.instruction + WORKER_CONTRACT,\n },\n metadata: { taskId: t.task_id, split } as unknown as Record<string, unknown>,\n }),\n )\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const meta = readMeta(task)\n const out = (await driver(['evaluate', '--task-id', meta.taskId, '--split', meta.split], artifact)) as {\n success?: boolean\n passes?: number\n fails?: number\n num_tests?: number\n failure_names?: string[]\n }\n const passes = out.passes ?? 0\n const fails = out.fails ?? 0\n // num_tests is the evaluator's authoritative per-requirement count; prefer it\n // over passes+fails (which can disagree if a requirement neither passed nor\n // failed). Never default the total to a phantom denominator.\n const total = out.num_tests ?? passes + fails\n const score = total > 0 ? passes / total : 0\n // failure_names = WHICH sub-tests failed — the evidence a trace analyst\n // steers on. Carried in `raw` (and `notes`) so it reaches the verdict.\n const failures = Array.isArray(out.failure_names) ? out.failure_names : []\n const raw = {\n taskId: meta.taskId,\n success: out.success,\n passes,\n fails,\n total,\n ...(failures.length ? { failures } : {}),\n }\n return {\n passed: out.success === true,\n score,\n notes: JSON.stringify(raw),\n raw,\n }\n },\n\n runtime: {\n output: appworldSolutionOutput,\n\n async preflight() {\n await preflightVenvImports({\n modules: ['appworld'],\n requireDocker: false,\n fix:\n 'Fix: bench/.venv/bin/pip install appworld ; ' +\n 'bench/.venv/bin/appworld install ; bench/.venv/bin/appworld download data ' +\n '(unpacks the engine + downloads the simulated-app data/tasks). ' +\n 'Set APPWORLD_ROOT to the data root if not the default.',\n })\n },\n\n async goldArtifact() {\n // Reference solution code ships only for train/dev, and only inside the\n // engine's decrypted `.bundle` (it is not a portable string this adapter can\n // emit across splits). The test splits are evaluation-only. So verify-judge\n // here requires a real solve on a train/dev task through the live engine\n // rather than a synthetic gold — returning a fabricated artifact would be a\n // fake. Returns undefined.\n return undefined\n },\n },\n })\n}\n\n/**\n * AppWorld in its NATIVE protocol, run by OUR runtime: the worker is\n * Runtime's profile-bound `router-tools` executor with one tool —\n * `execute_python` — bound to a persistent AppWorld world session. The driver's\n * `session` subcommand is a dumb world shim (stdin JSONL: execute → output,\n * evaluate → verdict); every inference turn, the metering, and the typed\n * toolTrace the analyst steers on belong to the runtime, so runtime\n * improvements are what this benchmark measures.\n *\n * The one-shot codegen adapter above plays a strictly harder game (no execution\n * feedback — the first wrong API call kills the whole program at judge time),\n * which flatlines the score against ANY steering; this mode is what the\n * benchmark's published baselines use, where behavior can move sub-tests.\n *\n * Protocol: the round task string is `@appworld-react <taskId> <split>` on\n * line 1; everything after line 1 is the steer (an analyst correction, a push\n * directive) appended to the system prompt — so the existing arms steer this\n * worker without modification. The artifact is the episode evaluation JSON\n * (AppWorld's evaluator ran in-world); evaluate() parses it, never re-executes.\n */\n\nexport interface ReactResult {\n success?: boolean\n passes?: number\n fails?: number\n num_tests?: number\n failure_names?: string[]\n turns?: number\n input_tokens?: number\n output_tokens?: number\n cost_usd?: number\n transcript?: string\n}\n\ninterface ReactRuntimeUsage {\n input: number\n output: number\n costUsd?: number\n tokensKnown?: boolean\n usdKnown?: boolean\n}\n\n/** Preserve a completed scientific/task result even when one accounting dimension is incomplete.\n * Unknown usage fields stay absent; later comparison/reporting can refuse a cost claim without\n * discarding the episode's task evidence. */\nexport function appworldReactResultWithUsage(\n verdict: ReactResult,\n usage: ReactRuntimeUsage,\n turns: number | undefined,\n transcript: string,\n): ReactResult {\n return {\n ...verdict,\n ...(turns !== undefined ? { turns } : {}),\n ...(usage.tokensKnown === false\n ? {}\n : { input_tokens: usage.input, output_tokens: usage.output }),\n ...(usage.usdKnown === false || usage.costUsd === undefined\n ? {}\n : { cost_usd: usage.costUsd }),\n transcript,\n }\n}\n\n/** Emit only usage the Runtime actually knows. Catalog estimates never become observed dollars. */\nexport function appworldReactUsageEvent(\n result: ReactResult,\n model: string,\n): { type: 'llm_call'; data: Record<string, unknown> } | undefined {\n const hasTokens =\n typeof result.input_tokens === 'number' && typeof result.output_tokens === 'number'\n const hasCost = typeof result.cost_usd === 'number'\n if (!hasTokens && !hasCost) return undefined\n return {\n type: 'llm_call',\n data: {\n model,\n ...(hasTokens\n ? { tokensIn: result.input_tokens, tokensOut: result.output_tokens }\n : {}),\n ...(hasCost ? { costUsd: result.cost_usd } : {}),\n },\n }\n}\n\nconst REACT_HEADER = /^@appworld-react (\\S+) (\\S+)\\n?/\n\nconst SESSION_SYSTEM = [\n 'You are completing a task in AppWorld, a simulated multi-app environment.',\n 'Use the execute_python tool to run Python that calls the app APIs (the `apis.<app>.<function>(...)` surface).',\n 'Inspect API docs with `apis.api_docs.show_api_descriptions(app_name=...)` and `apis.api_docs.show_api_doc(app_name=..., api_name=...)`.',\n 'Authenticate where needed via the supervisor-provided credentials (`apis.supervisor.show_account_passwords()`).',\n 'Work incrementally: small snippets, read each output, correct course.',\n 'When every step of the task is done, run `apis.supervisor.complete_task()` and then reply WITHOUT calling the tool again.',\n].join('\\n')\n\nconst EXECUTE_TOOL: ToolSpec = {\n type: 'function',\n function: {\n name: 'execute_python',\n description:\n 'Execute a Python snippet in the persistent AppWorld world. State persists across calls. Returns the execution output (API results or errors).',\n parameters: {\n type: 'object',\n properties: { code: { type: 'string', description: 'Python code calling apis.<app>.<fn>(...)' } },\n required: ['code'],\n },\n },\n}\n\n/** One persistent world session: line-JSONL request/response over the driver. */\nasync function withWorldSession<T>(\n taskId: string,\n split: string,\n signal: AbortSignal,\n fn: (call: (cmd: Record<string, unknown>) => Promise<Record<string, unknown>>, instruction: string) => Promise<T>,\n): Promise<T> {\n signal.throwIfAborted()\n const child = spawn(venvPython, [DRIVER, 'session', '--task-id', taskId, '--split', split], {\n cwd: benchRoot,\n })\n const stopChild = (): void => {\n if (!child.killed) child.kill('SIGTERM')\n }\n signal.addEventListener('abort', stopChild, { once: true })\n const rl = createInterface({ input: child.stdout })\n const pending: Array<(line: string) => void> = []\n const backlog: string[] = []\n rl.on('line', (l) => {\n const next = pending.shift()\n if (next) next(l)\n else backlog.push(l)\n })\n let stderr = ''\n child.stderr.on('data', (c: Buffer) => {\n stderr += c.toString('utf8')\n })\n const nextLine = (timeoutMs: number): Promise<string> =>\n new Promise((resolve, reject) => {\n if (signal.aborted) {\n reject(signal.reason)\n return\n }\n const fromBacklog = backlog.shift()\n if (fromBacklog !== undefined) return resolve(fromBacklog)\n const t = setTimeout(\n () => reject(new Error(`appworld session: no response in ${timeoutMs}ms; stderr: ${stderr.slice(-400)}`)),\n timeoutMs,\n )\n // One exit listener per await leaks (25-turn episodes blow the listener\n // cap) — remove it on the resolve path.\n const onExit = (code: number | null): void => {\n clearTimeout(t)\n signal.removeEventListener('abort', onAbort)\n reject(\n signal.aborted\n ? signal.reason\n : new Error(`appworld session exited (${code}); stderr: ${stderr.slice(-400)}`),\n )\n }\n const onAbort = (): void => {\n clearTimeout(t)\n child.removeListener('exit', onExit)\n const index = pending.indexOf(onLine)\n if (index >= 0) pending.splice(index, 1)\n reject(signal.reason)\n }\n const onLine = (line: string): void => {\n clearTimeout(t)\n child.removeListener('exit', onExit)\n signal.removeEventListener('abort', onAbort)\n resolve(line)\n }\n pending.push(onLine)\n child.once('exit', onExit)\n signal.addEventListener('abort', onAbort, { once: true })\n })\n try {\n const ready = JSON.parse(await nextLine(120_000)) as { ready?: boolean; instruction?: string; error?: string }\n if (!ready.ready) throw new Error(`appworld session failed to start: ${ready.error ?? 'no ready line'}`)\n const call = async (cmd: Record<string, unknown>): Promise<Record<string, unknown>> => {\n child.stdin.write(`${JSON.stringify(cmd)}\\n`)\n const res = JSON.parse(await nextLine(180_000)) as Record<string, unknown>\n if (typeof res.error === 'string') throw new Error(`appworld session op failed: ${res.error}`)\n return res\n }\n return await fn(call, ready.instruction ?? '')\n } finally {\n signal.removeEventListener('abort', stopChild)\n child.stdin.end()\n stopChild()\n }\n}\n\ntype AppWorldWorldSession = typeof withWorldSession\ntype AppWorldComplete = (\n body: Record<string, unknown>,\n request?: {\n readonly headers: Readonly<Record<string, string>>\n readonly signal?: AbortSignal\n },\n) => Promise<unknown>\n\n/** SandboxClient whose leaf is Runtime's profile-bound Router executor driving a world session. */\nexport function appworldToolLoopClient(cfg: {\n model: string\n routerBaseUrl: string\n routerKey: string\n maxTurns?: number\n /** Offline-test seam; production always uses the Python AppWorld session above. */\n runWorldSession?: AppWorldWorldSession\n /** Offline-test seam; production uses Runtime's Router HTTP transport. */\n complete?: AppWorldComplete\n}): unknown {\n const maxTurns = cfg.maxTurns ?? Number(process.env.REACT_MAX_TURNS ?? 40)\n const runWorldSession = cfg.runWorldSession ?? withWorldSession\n let seq = 0\n return {\n async create() {\n const id = `appworld-toolloop-${seq++}`\n return {\n id,\n async *streamPrompt(prompt: string, promptOpts?: { signal?: AbortSignal }) {\n const signal = promptOpts?.signal ?? new AbortController().signal\n signal.throwIfAborted()\n const m = prompt.match(REACT_HEADER)\n if (!m) {\n throw new Error(\n `appworld-react leaf: prompt missing '@appworld-react <taskId> <split>' header — got: ${prompt.slice(0, 120)}`,\n )\n }\n const [, taskId, split] = m\n const directive = prompt.replace(REACT_HEADER, '').trim()\n const out = await runWorldSession(taskId as string, split as string, signal, async (call, instruction) => {\n const system = directive ? `${SESSION_SYSTEM}\\n\\n${directive}` : SESSION_SYSTEM\n const transcriptSteps: Array<{ args: string; result: string }> = []\n const profile = {\n name: 'appworld-react-worker',\n harness: 'cli-base' as const,\n model: {\n provider: 'tangle-router',\n default: cfg.model,\n metadata: { maxTurns },\n },\n prompt: { systemPrompt: system },\n tools: { execute_python: true },\n }\n const factory = createExecutor({\n backend: 'router-tools',\n routerBaseUrl: cfg.routerBaseUrl,\n routerKey: cfg.routerKey,\n ...(cfg.complete ? { complete: cfg.complete } : {}),\n tools: [EXECUTE_TOOL],\n executeToolCall: async (name, args) => {\n if (name !== 'execute_python') return `error: unknown tool ${name}`\n const res = await call({ op: 'execute', code: String(args.code ?? '') })\n const done = res.task_completed === true\n const result = `${String(res.output ?? '')}${done ? '\\n\\n[TASK MARKED COMPLETE — reply with a final summary and do not call the tool again]' : ''}`\n transcriptSteps.push({ args: JSON.stringify(args), result })\n return result\n },\n })\n const loop = await collectAgentTurn(\n streamAgentTurn(\n { kind: 'executor', factory, profile },\n { prompt: `Task: ${instruction}` },\n { signal },\n ),\n )\n if (loop.status !== 'completed') {\n throw new Error(loop.error?.message ?? `AppWorld turn ended with ${loop.status}`)\n }\n const verdict = (await call({ op: 'evaluate' })) as unknown as ReactResult\n const transcript = transcriptSteps\n .slice(-3)\n .map((t) => `CODE:\\n${t.args.slice(0, 600)}\\nOUTPUT:\\n${t.result.slice(0, 600)}`)\n .join('\\n---\\n')\n .slice(0, 1600)\n const finalEvent = loop.events.at(-1)\n const resultMetadata =\n finalEvent?.type === 'final' && finalEvent.metadata?.result\n ? (finalEvent.metadata.result as { spent?: { iterations?: number } })\n : undefined\n return appworldReactResultWithUsage(\n verdict,\n loop.usage,\n resultMetadata?.spent?.iterations,\n transcript,\n )\n })\n const usageEvent = appworldReactUsageEvent(out, cfg.model)\n if (usageEvent) yield usageEvent\n yield { type: 'result', data: { finalText: JSON.stringify(out) } }\n },\n async delete() {},\n }\n },\n }\n}\n\n/** Artifact = the episode's evaluation JSON, verbatim (no fence extraction). */\nconst reactEpisodeOutput: OutputAdapter<string> = {\n parse(events) {\n let text = ''\n for (const ev of events) {\n const d = (ev as { data?: Record<string, unknown> })?.data\n const t = d?.finalText\n if (typeof t === 'string' && t.length > 0) text = t\n }\n return text\n },\n}\n\nexport function createAppWorldReactAdapter(): RuntimeBenchmark {\n const base = createAppWorldAdapter()\n return runtimeBenchmark({\n id: 'appworld-react',\n\n async loadAll(opts: LoadOptions = {}): Promise<BenchTask[]> {\n const tasks = await base.loadAll(opts)\n return tasks.map((t) => {\n const meta = readMeta(t)\n return {\n ...t,\n payload: {\n ...t.payload,\n // Header carries task identity to the leaf; the body (empty at round 0)\n // is the directive slot the arms append their steer into.\n prompt: `@appworld-react ${meta.taskId} ${meta.split}\\n`,\n },\n }\n })\n },\n\n async evaluate(task: BenchTask, artifact: string): Promise<BenchEvaluation> {\n const meta = readMeta(task)\n let out: ReactResult\n try {\n out = JSON.parse(artifact) as ReactResult\n } catch {\n throw new Error(\n `appworld-react judge: artifact is not the episode's evaluation JSON (task ${meta.taskId}): ${artifact.slice(0, 200)}`,\n )\n }\n if (typeof out.success !== 'boolean' || typeof out.num_tests !== 'number') {\n throw new Error(\n `appworld-react judge: episode JSON missing success/num_tests (task ${meta.taskId}): ${artifact.slice(0, 200)}`,\n )\n }\n const passes = out.passes ?? 0\n const total = out.num_tests\n const failures = Array.isArray(out.failure_names) ? out.failure_names : []\n const raw = {\n taskId: meta.taskId,\n success: out.success,\n passes,\n fails: out.fails ?? 0,\n total,\n turns: out.turns,\n ...(failures.length ? { failures } : {}),\n ...(out.transcript ? { transcriptTail: out.transcript.slice(-800) } : {}),\n }\n return {\n passed: out.success === true,\n score: total > 0 ? passes / total : 0,\n notes: JSON.stringify(raw),\n raw,\n }\n },\n\n runtime: {\n output: reactEpisodeOutput,\n preflight: async () => base.runtime.preflight?.(),\n goldArtifact: () => Promise.resolve(undefined),\n worker: (c) => appworldToolLoopClient(c),\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,SAAS,KAAK,WAAW,WAAW,oBAAoB;;AAG9D,MAAM,gBAAgB;;AAQtB,MAAa,yBAAgD,EAC3D,MAAM,QAAQ;CACZ,IAAI,OAAO;CACX,KAAK,MAAM,MAAM,QAAQ;EACvB,MAAM,IAAK,IAA2C;EACtD,MAAM,IAAI,GAAG,aAAa,GAAG,QAAQ,GAAG;EACxC,IAAI,OAAO,MAAM,YAAY,EAAE,SAAS,GAAG,OAAO;CACpD;CAEA,QAAQ,CADQ,GAAG,KAAK,SAAS,sCAAsC,CAC1D,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,KAAA,CAAM,KAAK;AAC3C,EACF;AAEA,MAAM,kBAAkB;CACtB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AAI,YAAY;IACxB,OAAO,QAAQ,IAAI,SAAS,QAAQ;IACpC,OAAO,KAAK,UAAU,GAAG;IACzB;GACF;EACF;EAEA,SAAS;GACP,QAAQ;GACR,WAAW,YAAY,KAAK,QAAQ,YAAY;GAChD,oBAAoB,QAAQ,QAAQ,KAAA,CAAS;GAC7C,SAAS,MAAM,uBAAuB,CAAC;EACzC;CACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
- import { BenchmarkAdapter } from "./types.js";
1
+ import { RuntimeBenchmark } from "./types.js";
2
2
  import { OutputAdapter } from "@tangle-network/agent-runtime/kernel";
3
3
  export declare const bfclOutput: OutputAdapter<string>;
4
- export declare function createBfclAdapter(): BenchmarkAdapter;
4
+ export declare function createBfclAdapter(): RuntimeBenchmark;
5
5
  //# sourceMappingURL=bfcl.d.ts.map