@tangle-network/agent-bench 0.14.2 → 1.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.
- package/CHANGELOG.md +48 -0
- package/README.md +2 -3
- package/dist/adapters.d.ts +2 -5
- package/dist/adapters.js +3 -4
- package/dist/benchmarks/_harness.d.ts +17 -20
- package/dist/benchmarks/_harness.js +4 -4
- package/dist/benchmarks/_harness.js.map +1 -1
- package/dist/benchmarks/aec-bench.d.ts +1 -4
- package/dist/benchmarks/aec-bench.js +1 -2
- package/dist/benchmarks/agentbench.d.ts +2 -5
- package/dist/benchmarks/agentbench.js +1 -2
- package/dist/benchmarks/appworld.d.ts +8 -10
- package/dist/benchmarks/appworld.js +23 -23
- package/dist/benchmarks/appworld.js.map +1 -1
- package/dist/benchmarks/bfcl.d.ts +2 -5
- package/dist/benchmarks/bfcl.js +1 -2
- package/dist/benchmarks/cad-design.d.ts +2 -5
- package/dist/benchmarks/cad-design.js +2 -3
- package/dist/benchmarks/cad-design.js.map +1 -1
- package/dist/benchmarks/cadbench.d.ts +1 -4
- package/dist/benchmarks/cadbench.js +1 -2
- package/dist/benchmarks/cadgenbench.d.ts +1 -4
- package/dist/benchmarks/cadgenbench.js +1 -2
- package/dist/benchmarks/commit0.d.ts +2 -5
- package/dist/benchmarks/commit0.js +1 -2
- package/dist/benchmarks/crag.d.ts +1 -4
- package/dist/benchmarks/crag.js +3 -3
- package/dist/benchmarks/crag.js.map +1 -1
- package/dist/benchmarks/dabstep.d.ts +2 -5
- package/dist/benchmarks/dabstep.js +2 -3
- package/dist/benchmarks/dabstep.js.map +1 -1
- package/dist/benchmarks/enterpriseops-gym.d.ts +2 -5
- package/dist/benchmarks/enterpriseops-gym.js +1 -2
- package/dist/benchmarks/finresearchbench.d.ts +2 -5
- package/dist/benchmarks/finresearchbench.js +2 -3
- package/dist/benchmarks/finsearchcomp.d.ts +2 -5
- package/dist/benchmarks/finsearchcomp.js +4 -4
- package/dist/benchmarks/finsearchcomp.js.map +1 -1
- package/dist/benchmarks/frames.d.ts +3 -19
- package/dist/benchmarks/frames.js +13 -39
- package/dist/benchmarks/frames.js.map +1 -1
- package/dist/benchmarks/hotpotqa.d.ts +4 -14
- package/dist/benchmarks/hotpotqa.js +12 -32
- package/dist/benchmarks/hotpotqa.js.map +1 -1
- package/dist/benchmarks/humaneval.d.ts +9 -12
- package/dist/benchmarks/humaneval.js +2 -3
- package/dist/benchmarks/humaneval.js.map +1 -1
- package/dist/benchmarks/mcad-bench.d.ts +13 -16
- package/dist/benchmarks/mcad-bench.js +2 -3
- package/dist/benchmarks/mcad-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-bench.d.ts +17 -20
- package/dist/benchmarks/mcad-cq-bench.js +2 -3
- package/dist/benchmarks/mcad-cq-bench.js.map +1 -1
- package/dist/benchmarks/mcad-cq-golds.d.ts +2 -5
- package/dist/benchmarks/mcad-cq-golds.js +1 -2
- package/dist/benchmarks/mcad-golds.d.ts +1 -4
- package/dist/benchmarks/mcad-golds.js +0 -1
- package/dist/benchmarks/mcad-tasks.d.ts +5 -8
- package/dist/benchmarks/mcad-tasks.js +7 -8
- package/dist/benchmarks/mcad-tasks.js.map +1 -1
- package/dist/benchmarks/mind2web.d.ts +3 -5
- package/dist/benchmarks/mind2web.js +2 -3
- package/dist/benchmarks/mind2web.js.map +1 -1
- package/dist/benchmarks/nomiracl.d.ts +1 -4
- package/dist/benchmarks/nomiracl.js +1 -2
- package/dist/benchmarks/open-rag-bench.d.ts +1 -4
- package/dist/benchmarks/open-rag-bench.js +3 -3
- package/dist/benchmarks/open-rag-bench.js.map +1 -1
- package/dist/benchmarks/programbench.d.ts +2 -5
- package/dist/benchmarks/programbench.js +1 -2
- package/dist/benchmarks/rag-shared.d.ts +30 -22
- package/dist/benchmarks/rag-shared.js +8 -2
- package/dist/benchmarks/rag-shared.js.map +1 -1
- package/dist/benchmarks/ragbench.d.ts +1 -4
- package/dist/benchmarks/ragbench.js +3 -3
- package/dist/benchmarks/ragbench.js.map +1 -1
- package/dist/benchmarks/simpleqa.d.ts +2 -18
- package/dist/benchmarks/simpleqa.js +5 -31
- package/dist/benchmarks/simpleqa.js.map +1 -1
- package/dist/benchmarks/swe-bench.d.ts +7 -10
- package/dist/benchmarks/swe-bench.js +4 -4
- package/dist/benchmarks/swe-bench.js.map +1 -1
- package/dist/benchmarks/t2-ragbench.d.ts +1 -4
- package/dist/benchmarks/t2-ragbench.js +3 -3
- package/dist/benchmarks/t2-ragbench.js.map +1 -1
- package/dist/benchmarks/tau-bench-shared.d.ts +5 -8
- package/dist/benchmarks/tau-bench-shared.js +4 -4
- package/dist/benchmarks/tau-bench-shared.js.map +1 -1
- package/dist/benchmarks/tau2-bench.d.ts +2 -5
- package/dist/benchmarks/tau2-bench.js +1 -2
- package/dist/benchmarks/tau3-banking.d.ts +1 -4
- package/dist/benchmarks/tau3-banking.js +1 -2
- package/dist/benchmarks/terminal-bench.d.ts +1 -4
- package/dist/benchmarks/terminal-bench.js +4 -4
- package/dist/benchmarks/terminal-bench.js.map +1 -1
- package/dist/benchmarks/toollm.d.ts +2 -5
- package/dist/benchmarks/toollm.js +1 -2
- package/dist/benchmarks/trata-hedge.d.ts +1 -4
- package/dist/benchmarks/trata-hedge.js +2 -3
- package/dist/benchmarks/types.d.ts +6 -9
- package/dist/benchmarks/webarena-verified.d.ts +2 -5
- package/dist/benchmarks/webarena-verified.js +1 -2
- package/dist/{cadbench-BRF-59Mt.js → cadbench-DhAndllg.js} +4 -6
- package/dist/cadbench-DhAndllg.js.map +1 -0
- package/dist/{cadgenbench-DXtGkuW3.js → cadgenbench-Tvk16YKT.js} +15 -5
- package/dist/cadgenbench-Tvk16YKT.js.map +1 -0
- package/dist/index.d.ts +8 -18
- package/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/{router-turn-uTYO6KQ1.js → router-turn-DNbQ_GjQ.js} +2 -3
- package/dist/router-turn-DNbQ_GjQ.js.map +1 -0
- package/fixtures/pier-agent/no-model-task/pre_artifacts.sh +0 -0
- package/fixtures/pier-agent/no-model-task/tests/test.sh +0 -0
- package/package.json +10 -10
- package/pier_agents/tangle_candidate.py +15 -23
- package/scripts/run-package-tests.mjs +8 -15
- package/scripts/verify-packed-consumer.mjs +0 -1
- package/src/atom-mcp-e2e.mts +16 -4
- package/src/benchmarks/frames.ts +10 -44
- package/src/benchmarks/hotpotqa.ts +9 -29
- package/src/benchmarks/rag-shared.ts +12 -0
- package/src/benchmarks/simpleqa.ts +2 -36
- package/src/commit0-prereqs.sh +0 -0
- package/src/corpus-replay.mts +8 -8
- package/src/corpus-report.mts +21 -21
- package/src/corpus.test.mts +5 -5
- package/src/corpus.ts +16 -16
- package/src/directives.ts +0 -38
- package/src/examples/lean-verify.ts +1 -1
- package/src/gate.ts +8 -8
- package/src/generate-eval/certify.ts +2 -2
- package/src/index.ts +1 -0
- package/src/refine-loop.ts +5 -5
- package/src/resolve-client.ts +1 -1
- package/src/router-turn.ts +3 -11
- package/src/run-benchmarks.test.mts +0 -4
- package/src/run-pool.ts +1 -1
- package/src/runtime-hook-recorder.ts +2 -2
- package/src/search-bench/tasks.ts +1 -1
- package/src/selector.test.mts +13 -13
- package/src/selector.ts +19 -19
- package/src/swe-bench-env.ts +4 -12
- package/src/swe-jail.ts +5 -156
- package/src/swe-structural-judge-policy.ts +3 -3
- package/src/swe-structural-policy.ts +3 -3
- package/src/swe-structural-provenance.ts +4 -4
- package/src/terminal-compare.ts +10 -10
- package/src/worker-blender.ts +2 -106
- package/src/worker-build123d.ts +2 -81
- package/tb_agents/opencode_router_agent.py +1 -1
- package/dist/cadbench-BRF-59Mt.js.map +0 -1
- package/dist/cadgenbench-DXtGkuW3.js.map +0 -1
- package/dist/router-turn-uTYO6KQ1.js.map +0 -1
- package/scripts/cadbench_prepare.py +0 -22
- package/scripts/cadgenbench_hard_parts.py +0 -48
- package/scripts/clbench_codebase_judge.py +0 -73
- package/scripts/render-gate-chart.mjs +0 -176
- package/scripts/trata-hedge/README.md +0 -57
- package/scripts/trata-hedge/run.sh +0 -64
- package/src/browser/adapters/bad-design-audit.ts +0 -153
- package/src/browser/adapters/bad-design-audit.verify.ts +0 -85
- package/src/browser/adapters/bad.ts +0 -165
- package/src/browser/agent-adapter.ts +0 -145
- package/src/browser/process-adapter.ts +0 -146
- package/src/browser/run-to-spans.ts +0 -105
- package/src/browser/run-to-spans.verify.ts +0 -89
- package/src/browser/ui-reviewer.ts +0 -200
- package/src/browser/ui-reviewer.verify.ts +0 -94
- package/src/browser/verify.ts +0 -96
- package/src/clbench-codebase-gate.mts +0 -314
- package/src/clbench-context-gate.mts +0 -341
- package/src/cloud-loop.mts +0 -156
- package/src/commit0-env-run.mts +0 -62
- package/src/commit0-env.ts +0 -172
- package/src/commit0-gate.mts +0 -558
- package/src/coordination-mcp-container-reach.mts +0 -182
- package/src/egress-probe.mts +0 -26
- package/src/fleet.mts +0 -143
- package/src/hev-structural.mts +0 -697
- package/src/humaneval-gate.mts +0 -220
- package/src/humaneval-repair-gate.mts +0 -182
- package/src/mbpp-structural.mts +0 -676
- package/src/mcp-mount-probe.mts +0 -139
- package/src/profile-coordinates.ts +0 -134
- package/src/profiles.ts +0 -128
- package/src/research-gate.mts +0 -132
- package/src/research-shot.ts +0 -144
- package/src/router-executor.ts +0 -51
- package/src/run-benchmarks-report.ts +0 -66
- package/src/sandbox-run.ts +0 -108
- package/src/search-bench/bridge.ts +0 -182
- package/src/search-bench/export.mts +0 -0
- package/src/search-bench/parametric-check.mts +0 -78
- package/src/search-bench/profiles.ts +0 -113
- package/src/search-bench/run.mts +0 -286
- package/src/search-bench/tasks-fresh.ts +0 -688
- package/src/skill-sandbox-smoke.mts +0 -101
- package/src/smoke-structural-rollout.mts +0 -415
- package/src/stats.mts +0 -90
- package/src/supervisor-arena.mts +0 -825
- package/src/swe-code-improve.mts +0 -306
- package/src/swe-emit-patch.mts +0 -125
- package/src/swe-improve.mts +0 -284
- package/src/swe-local-proof.mts +0 -265
- package/src/swe-repro-calibrate.mts +0 -451
- package/src/swe-stream.mts +0 -1561
- package/src/swe-structural.mts +0 -707
- package/src/tb-container-executor.mts +0 -266
- package/src/tb-container-executor.test.mts +0 -134
- package/src/tb-supervisor-sidecar.mts +0 -208
- package/src/trajectory-assemble.mjs +0 -130
- package/src/trata-gepa.mts +0 -381
- package/src/trata-hedge-solve.mts +0 -81
- package/src/worker-browser.ts +0 -115
- package/src/worker-cad.ts +0 -470
- package/src/workspace-loop.mts +0 -133
- package/tb_agents/opencode_refine_agent.py +0 -117
- package/tb_agents/opencode_supervisor_agent.py +0 -239
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manual reachability probe for the coordination MCP from inside a Docker container.
|
|
3
|
-
*
|
|
4
|
-
* Run: `npx tsx bench/src/coordination-mcp-container-reach.mts`.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { execFile } from 'node:child_process'
|
|
8
|
-
import { promisify } from 'node:util'
|
|
9
|
-
|
|
10
|
-
const execFileAsync = promisify(execFile)
|
|
11
|
-
import {
|
|
12
|
-
type Agent,
|
|
13
|
-
type AgentProfile,
|
|
14
|
-
type AgentSpec,
|
|
15
|
-
createExecutorRegistry,
|
|
16
|
-
createSupervisor,
|
|
17
|
-
type Executor,
|
|
18
|
-
type ExecutorResult,
|
|
19
|
-
InMemoryResultBlobStore,
|
|
20
|
-
InMemorySpawnJournal,
|
|
21
|
-
type Scope,
|
|
22
|
-
type UsageEvent,
|
|
23
|
-
} from '../../src/runtime/index'
|
|
24
|
-
import { serveCoordinationMcp } from '../../src/runtime/supervise/coordination-mcp'
|
|
25
|
-
|
|
26
|
-
const HOST_BIND = '0.0.0.0'
|
|
27
|
-
const DOCKER_BRIDGE_GATEWAY = process.env.DOCKER_BRIDGE_GATEWAY ?? '172.17.0.1'
|
|
28
|
-
|
|
29
|
-
function trivialWorker(name: string): Agent<unknown, unknown> {
|
|
30
|
-
const ex: Executor<unknown> = {
|
|
31
|
-
runtime: 'router',
|
|
32
|
-
execute() {
|
|
33
|
-
return (async function* () {
|
|
34
|
-
yield { kind: 'iteration' } as UsageEvent
|
|
35
|
-
})()
|
|
36
|
-
},
|
|
37
|
-
teardown: () => Promise.resolve({ destroyed: true }),
|
|
38
|
-
resultArtifact: (): ExecutorResult<unknown> => ({
|
|
39
|
-
outRef: `w:${name}`,
|
|
40
|
-
out: { ok: true },
|
|
41
|
-
verdict: { valid: true, score: 1 },
|
|
42
|
-
spent: { iterations: 1, tokens: { input: 0, output: 0 }, usd: 0, ms: 0 },
|
|
43
|
-
}),
|
|
44
|
-
}
|
|
45
|
-
const spec: AgentSpec = { profile: { name } as AgentProfile, harness: null, executor: ex }
|
|
46
|
-
return { name, act: async () => ({ ok: true }), executorSpec: spec } as Agent<unknown, unknown> & {
|
|
47
|
-
executorSpec: AgentSpec
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface ToolsListResponse {
|
|
52
|
-
result?: { tools?: Array<{ name: string; description?: string; inputSchema?: unknown }> }
|
|
53
|
-
error?: { code: number; message: string }
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function dockerCurlToolsList(
|
|
57
|
-
containerUrl: string,
|
|
58
|
-
): Promise<{ raw: string; parsed: ToolsListResponse; cmd: string }> {
|
|
59
|
-
const rpc = JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/list' })
|
|
60
|
-
const args = [
|
|
61
|
-
'run',
|
|
62
|
-
'--rm',
|
|
63
|
-
'--add-host',
|
|
64
|
-
'host.docker.internal:host-gateway',
|
|
65
|
-
'curlimages/curl',
|
|
66
|
-
'-s',
|
|
67
|
-
'-X',
|
|
68
|
-
'POST',
|
|
69
|
-
containerUrl,
|
|
70
|
-
'-H',
|
|
71
|
-
'content-type: application/json',
|
|
72
|
-
'-d',
|
|
73
|
-
rpc,
|
|
74
|
-
]
|
|
75
|
-
const cmd = `docker ${args.join(' ')}`
|
|
76
|
-
const { stdout } = await execFileAsync('docker', args, { encoding: 'utf8', timeout: 120_000 })
|
|
77
|
-
return { raw: stdout, parsed: JSON.parse(stdout) as ToolsListResponse, cmd }
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function opencodeConfigSnippet(containerUrl: string): string {
|
|
81
|
-
return JSON.stringify(
|
|
82
|
-
{
|
|
83
|
-
$schema: 'https://opencode.ai/config.json',
|
|
84
|
-
permission: {
|
|
85
|
-
external_directory: 'allow',
|
|
86
|
-
bash: 'allow',
|
|
87
|
-
edit: 'allow',
|
|
88
|
-
read: 'allow',
|
|
89
|
-
write: 'allow',
|
|
90
|
-
webfetch: 'allow',
|
|
91
|
-
task: 'allow',
|
|
92
|
-
plan_enter: 'allow',
|
|
93
|
-
plan_exit: 'allow',
|
|
94
|
-
question: 'allow',
|
|
95
|
-
},
|
|
96
|
-
mcp: {
|
|
97
|
-
coordination: {
|
|
98
|
-
type: 'remote',
|
|
99
|
-
url: containerUrl,
|
|
100
|
-
enabled: true,
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
null,
|
|
105
|
-
2,
|
|
106
|
-
)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function main(): Promise<void> {
|
|
110
|
-
const blobs = new InMemoryResultBlobStore()
|
|
111
|
-
let ok = false
|
|
112
|
-
|
|
113
|
-
const root: Agent<unknown, unknown> = {
|
|
114
|
-
name: 'coordination-mcp-container-reach',
|
|
115
|
-
async act(_t, scope: Scope<unknown>) {
|
|
116
|
-
const mcp = await serveCoordinationMcp({
|
|
117
|
-
scope,
|
|
118
|
-
blobs,
|
|
119
|
-
makeWorkerAgent: () => trivialWorker('w'),
|
|
120
|
-
perWorker: { maxIterations: 4, maxTokens: 2000 },
|
|
121
|
-
toolNames: ['spawn_worker', 'await_event'],
|
|
122
|
-
host: HOST_BIND,
|
|
123
|
-
})
|
|
124
|
-
// Docker containers reach the host through the bridge gateway, not the 0.0.0.0 bind URL.
|
|
125
|
-
const containerUrl = `http://${DOCKER_BRIDGE_GATEWAY}:${mcp.port}/mcp`
|
|
126
|
-
const hostDockerInternalUrl = `http://host.docker.internal:${mcp.port}/mcp`
|
|
127
|
-
|
|
128
|
-
console.error(`[probe] host-binding used : ${HOST_BIND}`)
|
|
129
|
-
console.error(`[probe] server url (mcp.url) : ${mcp.url}`)
|
|
130
|
-
console.error(`[probe] container-reachable url : ${containerUrl}`)
|
|
131
|
-
console.error(`[probe] alt (host.docker.internal) : ${hostDockerInternalUrl}`)
|
|
132
|
-
console.error('')
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
console.error('[probe] POSTing tools/list from inside a docker container ...')
|
|
136
|
-
const { raw, parsed, cmd } = await dockerCurlToolsList(containerUrl)
|
|
137
|
-
console.error(`[probe] container ran: ${cmd}`)
|
|
138
|
-
console.error(`[probe] container got back (${raw.length} bytes):`)
|
|
139
|
-
console.error(raw)
|
|
140
|
-
console.error('')
|
|
141
|
-
|
|
142
|
-
const toolNames = (parsed.result?.tools ?? []).map((t) => t.name)
|
|
143
|
-
const hasSpawn = toolNames.includes('spawn_worker')
|
|
144
|
-
const hasAwait = toolNames.includes('await_event')
|
|
145
|
-
console.error(`[probe] tools advertised: ${toolNames.join(', ')}`)
|
|
146
|
-
console.error(`[probe] spawn_worker present = ${hasSpawn}; await_event present = ${hasAwait}`)
|
|
147
|
-
ok = hasSpawn && hasAwait
|
|
148
|
-
|
|
149
|
-
if (ok) {
|
|
150
|
-
console.error('')
|
|
151
|
-
console.error('[probe] opencode.json snippet (arm B writes this via OPENCODE_CONFIG):')
|
|
152
|
-
console.error(opencodeConfigSnippet(containerUrl))
|
|
153
|
-
}
|
|
154
|
-
return ok ? { reachable: true } : undefined
|
|
155
|
-
} finally {
|
|
156
|
-
await mcp.close()
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
await createSupervisor<unknown, unknown>().run(root, 'reach', {
|
|
162
|
-
budget: { maxIterations: 100, maxTokens: 400_000 },
|
|
163
|
-
runId: 'coordination-mcp-container-reach',
|
|
164
|
-
journal: new InMemorySpawnJournal(),
|
|
165
|
-
blobs,
|
|
166
|
-
executors: createExecutorRegistry(),
|
|
167
|
-
maxDepth: 4,
|
|
168
|
-
now: () => Date.now(),
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
console.error(
|
|
172
|
-
ok
|
|
173
|
-
? 'CONTAINER-REACHABLE: docker tools/list returned spawn_worker and await_event.'
|
|
174
|
-
: 'NOT reachable from container; see output above.',
|
|
175
|
-
)
|
|
176
|
-
process.exit(ok ? 0 : 1)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
main().catch((e) => {
|
|
180
|
-
console.error(e instanceof Error ? (e.stack ?? e.message) : String(e))
|
|
181
|
-
process.exit(1)
|
|
182
|
-
})
|
package/src/egress-probe.mts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandbox->router egress probe: spins a box and makes one model-free authenticated API read from
|
|
3
|
-
* https://router.tangle.tools/v1 using the BOX-PROVISIONED key (OPENCODE_MODEL_API_KEY
|
|
4
|
-
* inside the box). That is the sanctioned flow: the egress proxy validates/injects
|
|
5
|
-
* credentials at the boundary and 403s foreign keys passed in from outside — a raw
|
|
6
|
-
* external key in this probe would report a false "blocked".
|
|
7
|
-
* dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- npx tsx src/egress-probe.mts
|
|
8
|
-
*/
|
|
9
|
-
import { Sandbox } from '@tangle-network/sandbox'
|
|
10
|
-
|
|
11
|
-
const key = process.env.SANDBOX_KEY ?? process.env.TANGLE_API_KEY
|
|
12
|
-
if (!key) throw new Error('no SANDBOX_KEY/TANGLE_API_KEY')
|
|
13
|
-
const client = new Sandbox({ baseUrl: process.env.SANDBOX_BASE_URL ?? 'https://sandbox.tangle.tools', apiKey: key, timeoutMs: 300_000 } as never)
|
|
14
|
-
const box = await client.create({ name: 'egress-probe' } as never)
|
|
15
|
-
console.log('sandbox up:', box.id)
|
|
16
|
-
const out = (r: unknown) => ((r as { stdout?: string }).stdout ?? '').trim()
|
|
17
|
-
try {
|
|
18
|
-
for (const h of ['router.tangle.tools', 'id.tangle.tools']) {
|
|
19
|
-
const r = await box.exec(`curl -s -o /dev/null -w '%{http_code}' --max-time 15 https://${h}/ || echo FAIL`)
|
|
20
|
-
console.log(h, '→', out(r))
|
|
21
|
-
}
|
|
22
|
-
const models = await box.exec(`curl -s --max-time 30 https://router.tangle.tools/v1/models -H "Authorization: Bearer $OPENCODE_MODEL_API_KEY" -o /tmp/b -w '%{http_code}'; echo ' |'; head -c 250 /tmp/b`)
|
|
23
|
-
console.log('models API (box-provisioned key):', out(models) || 'EMPTY — egress broken')
|
|
24
|
-
} finally {
|
|
25
|
-
await box.delete()
|
|
26
|
-
}
|
package/src/fleet.mts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The whole vision, end to end, runnable from a laptop: a thin local driver
|
|
3
|
-
* fans out N workers to CLOUD sandboxes, observes each worker's trace, reports
|
|
4
|
-
* what to fix, and writes durable learnings to a corpus the NEXT run reads back.
|
|
5
|
-
*
|
|
6
|
-
* Local process = the driver (orchestrate + observe). All agent work runs in the
|
|
7
|
-
* cloud (Tangle sandbox SDK). Scale is the API key, not the laptop.
|
|
8
|
-
*
|
|
9
|
-
* dotenvx run -f ~/company/devops/secrets/.env.keys -f ~/company/devops/secrets/agent-state.env -- \
|
|
10
|
-
* env BACKEND=opencode MODEL=gpt-4.1 N=2 CORPUS=/tmp/fleet-corpus.jsonl \
|
|
11
|
-
* pnpm exec tsx src/fleet.mts
|
|
12
|
-
*
|
|
13
|
-
* Run it twice: the second run injects the first run's learnings into the workers.
|
|
14
|
-
*/
|
|
15
|
-
import {
|
|
16
|
-
defaultAnalystInstruction,
|
|
17
|
-
FileCorpus,
|
|
18
|
-
observe,
|
|
19
|
-
openSandboxRun,
|
|
20
|
-
renderReport,
|
|
21
|
-
} from '@tangle-network/agent-runtime/kernel'
|
|
22
|
-
import { Sandbox } from '@tangle-network/sandbox'
|
|
23
|
-
import { answerOutput, sandboxAgentRun, type WorkerBackendType } from './sandbox-run'
|
|
24
|
-
|
|
25
|
-
function env(name: string, fallback?: string): string {
|
|
26
|
-
const v = process.env[name] ?? fallback
|
|
27
|
-
if (v === undefined) throw new Error(`missing env ${name}`)
|
|
28
|
-
return v
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// The fleet's work: each worker gets one subtask. Swap for any real decomposition.
|
|
32
|
-
const subtasks = [
|
|
33
|
-
'Write a Python function `is_prime(n)` and three asserts proving it. Run them and report PASS/FAIL.',
|
|
34
|
-
'Write a Python function `fib(n)` (iterative) and three asserts proving it. Run them and report PASS/FAIL.',
|
|
35
|
-
'Write a Python function `rev_words(s)` that reverses word order, with asserts. Run them and report PASS/FAIL.',
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
interface WorkerResult {
|
|
39
|
-
id: string
|
|
40
|
-
task: string
|
|
41
|
-
output: string
|
|
42
|
-
events: unknown[]
|
|
43
|
-
wallMs: number
|
|
44
|
-
error?: string
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function runWorker(
|
|
48
|
-
client: Sandbox,
|
|
49
|
-
cfg: { backendType: WorkerBackendType; model: string; provider: string; routerBaseUrl: string },
|
|
50
|
-
id: string,
|
|
51
|
-
task: string,
|
|
52
|
-
priorLearnings: string,
|
|
53
|
-
): Promise<WorkerResult> {
|
|
54
|
-
const startedAt = Date.now()
|
|
55
|
-
const prompt = priorLearnings ? `${priorLearnings}\n\n---\n\n${task}` : task
|
|
56
|
-
const controller = new AbortController()
|
|
57
|
-
const timer = setTimeout(() => controller.abort(), Number(process.env.TIMEOUT_MS ?? 240_000))
|
|
58
|
-
try {
|
|
59
|
-
const agentRun = sandboxAgentRun({
|
|
60
|
-
profile: {
|
|
61
|
-
name: id,
|
|
62
|
-
harness: cfg.backendType,
|
|
63
|
-
model: { provider: cfg.provider, default: cfg.model },
|
|
64
|
-
},
|
|
65
|
-
})
|
|
66
|
-
const run = await openSandboxRun<string>(
|
|
67
|
-
client,
|
|
68
|
-
{ agentRun, signal: controller.signal },
|
|
69
|
-
{ kind: 'events', fromEvents: (events) => answerOutput.parse(events as never) },
|
|
70
|
-
)
|
|
71
|
-
try {
|
|
72
|
-
const turn = await run.start(prompt)
|
|
73
|
-
return { id, task, output: (turn.out ?? '').trim(), events: turn.events, wallMs: Date.now() - startedAt }
|
|
74
|
-
} finally {
|
|
75
|
-
await run.close().catch(() => {})
|
|
76
|
-
}
|
|
77
|
-
} catch (err) {
|
|
78
|
-
return { id, task, output: '', events: [], wallMs: Date.now() - startedAt, error: err instanceof Error ? err.message : String(err) }
|
|
79
|
-
} finally {
|
|
80
|
-
clearTimeout(timer)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async function main(): Promise<void> {
|
|
85
|
-
const routerKey = env('TANGLE_API_KEY')
|
|
86
|
-
const cfg = {
|
|
87
|
-
backendType: env('BACKEND', 'opencode') as WorkerBackendType,
|
|
88
|
-
model: env('MODEL', 'deepseek-v4-flash'),
|
|
89
|
-
provider: env('WORKER_PROVIDER', 'openai-compat'),
|
|
90
|
-
routerBaseUrl: env('ROUTER_BASE_URL', 'https://router.tangle.tools/v1'),
|
|
91
|
-
}
|
|
92
|
-
const n = Math.min(Number(env('N', '2')), subtasks.length)
|
|
93
|
-
const corpus = new FileCorpus(env('CORPUS', '/tmp/fleet-corpus.jsonl'))
|
|
94
|
-
const observerModel = env('OBSERVER_MODEL', 'deepseek-v4-flash')
|
|
95
|
-
const observerProfile = {
|
|
96
|
-
name: 'fleet-observer',
|
|
97
|
-
harness: 'cli-base' as const,
|
|
98
|
-
model: { provider: 'tangle-router', default: observerModel },
|
|
99
|
-
prompt: { systemPrompt: defaultAnalystInstruction },
|
|
100
|
-
}
|
|
101
|
-
const client = new Sandbox({ baseUrl: env('SANDBOX_BASE_URL', 'https://sandbox.tangle.tools'), apiKey: routerKey })
|
|
102
|
-
|
|
103
|
-
// ── continuous: read what prior runs LEARNED, inject it into this run's workers
|
|
104
|
-
const prior = await corpus.query({ tags: ['audience:agent'], limit: 8 })
|
|
105
|
-
const priorLearnings = prior.length
|
|
106
|
-
? `PRIOR LEARNINGS (from earlier runs — apply them):\n${prior.map((r) => `- ${r.claim}`).join('\n')}`
|
|
107
|
-
: ''
|
|
108
|
-
console.error(`\n=== FLEET · ${n} workers · ${cfg.backendType}/${cfg.model} · cloud ===`)
|
|
109
|
-
console.error(prior.length ? `carrying ${prior.length} prior learning(s) into the workers\n` : 'first run — no prior learnings yet\n')
|
|
110
|
-
|
|
111
|
-
// ── fan out N workers to cloud sandboxes, in parallel
|
|
112
|
-
const tasks = subtasks.slice(0, n)
|
|
113
|
-
const workers = await Promise.all(
|
|
114
|
-
tasks.map((task, i) => runWorker(client, cfg, `worker-${i + 1}`, task, priorLearnings)),
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
// ── observe each worker's trace → findings → operator report + durable learnings
|
|
118
|
-
let totalLearned = 0
|
|
119
|
-
for (const w of workers) {
|
|
120
|
-
console.error(`\n── ${w.id} (${Math.round(w.wallMs / 1000)}s)${w.error ? ` — ERROR: ${w.error}` : ''}`)
|
|
121
|
-
if (w.error) continue
|
|
122
|
-
const ob = await observe(
|
|
123
|
-
{ task: w.task, output: w.output, trace: w.events, outcome: w.output ? 'passed' : 'unknown', runId: w.id },
|
|
124
|
-
{
|
|
125
|
-
profile: observerProfile,
|
|
126
|
-
executor: { backend: 'router', routerBaseUrl: cfg.routerBaseUrl, routerKey },
|
|
127
|
-
corpus,
|
|
128
|
-
tags: [cfg.backendType, 'fleet'],
|
|
129
|
-
},
|
|
130
|
-
)
|
|
131
|
-
totalLearned += ob.learned.length
|
|
132
|
-
console.error(` answer: ${w.output.slice(0, 120).replace(/\n/g, ' ')}`)
|
|
133
|
-
console.error(renderReport(ob.findings).split('\n').map((l) => ` ${l}`).join('\n'))
|
|
134
|
-
console.error(` → ${ob.learned.length} new learning(s) saved to the corpus`)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
console.error(`\n=== fleet done: ${workers.filter((w) => !w.error).length}/${n} workers ok · ${totalLearned} learnings banked → run again to apply them ===`)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
main().catch((e) => {
|
|
141
|
-
console.error(e)
|
|
142
|
-
process.exit(1)
|
|
143
|
-
})
|