This commit is contained in:
@@ -29,6 +29,40 @@ test('mutate paths use a denylist (base system read-only, rest writable)', async
|
||||
t.absent(s.bareAgentPathAllowedMutate('/'))
|
||||
})
|
||||
|
||||
test('js script wrapping curl/fetch diverts to a shell command', async (t) => {
|
||||
const s = load()
|
||||
const fromJs = s.bareAgentShellCommandFromJsScript
|
||||
t.is(
|
||||
fromJs("await ctx.execLine('curl http://api.ipify.org')"),
|
||||
'curl http://api.ipify.org'
|
||||
)
|
||||
t.is(
|
||||
fromJs("const r = await fetch('https://api.ipify.org')"),
|
||||
'curl -s https://api.ipify.org'
|
||||
)
|
||||
t.is(fromJs('curl http://api.ipify.org'), 'curl http://api.ipify.org')
|
||||
t.is(fromJs('const vfs = ctx.vfs\nawait vfs.readFile("/tmp/x")'), '')
|
||||
})
|
||||
|
||||
test('failed task_complete detector matches screenshot surrender', async (t) => {
|
||||
const s = load()
|
||||
const fn = s.bareAgentLooksLikeFailedTaskComplete
|
||||
t.ok(
|
||||
fn(
|
||||
'Done: Attempted to retrieve IP address using JavaScript. Error occurred due to async/await in top-level scope. Alternative method required.'
|
||||
)
|
||||
)
|
||||
t.absent(fn('Fetched public IP via curl; stdout is 1.2.3.4'))
|
||||
})
|
||||
|
||||
test('guest CLI request detector matches run curl for IP', async (t) => {
|
||||
const s = load()
|
||||
const fn = s.bareAgentLooksLikeGuestCliRequest
|
||||
t.ok(fn('run curl to find our IP Address'))
|
||||
t.ok(fn('get our public ip'))
|
||||
t.absent(fn('refactor the agent prompt'))
|
||||
})
|
||||
|
||||
test('normalize guest script strips ctx redeclare and export', async (t) => {
|
||||
const s = load()
|
||||
const n = s.bareAgentNormalizeGuestScript
|
||||
|
||||
Reference in New Issue
Block a user