feat: add agent ID/name resolution and provider/model syntax support
This commit is contained in:
@@ -130,6 +130,17 @@ try {
|
||||
console.log('✓ run --provider flag is accepted\n')
|
||||
}
|
||||
|
||||
// Test 6b: run --provider provider/model syntax is accepted
|
||||
{
|
||||
console.log('Test 6b: run --provider provider/model syntax is accepted')
|
||||
const result =
|
||||
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --provider codex/gpt-5.4 "test prompt"`.nothrow()
|
||||
const output = result.stdout + result.stderr
|
||||
assert(!output.includes('unknown option'), 'should accept provider/model syntax')
|
||||
assert(!output.includes('error: option'), 'should not have option parsing error')
|
||||
console.log('✓ run --provider provider/model syntax is accepted\n')
|
||||
}
|
||||
|
||||
// Test 7: run --mode flag is accepted
|
||||
{
|
||||
console.log('Test 7: run --mode flag is accepted')
|
||||
@@ -199,6 +210,17 @@ try {
|
||||
console.log('✓ Combined flags work together\n')
|
||||
}
|
||||
|
||||
// Test 12b: conflicting provider/model syntax is rejected before connect
|
||||
{
|
||||
console.log('Test 12b: conflicting provider/model syntax is rejected')
|
||||
const result =
|
||||
await $`PASEO_HOST=localhost:${port} PASEO_HOME=${paseoHome} npx paseo run --provider codex/gpt-5.4 --model gpt-5.5 "test prompt"`.nothrow()
|
||||
assert.notStrictEqual(result.exitCode, 0, 'should fail for conflicting model inputs')
|
||||
const output = result.stdout + result.stderr
|
||||
assert(output.includes('Conflicting model values provided'), 'should explain conflicting model inputs')
|
||||
console.log('✓ conflicting provider/model syntax is rejected\n')
|
||||
}
|
||||
|
||||
// Test 13: paseo --help shows run command
|
||||
{
|
||||
console.log('Test 13: paseo --help shows run command')
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import assert from 'node:assert'
|
||||
import {
|
||||
resolveProviderAndModel,
|
||||
resolveStructuredResponseMessage,
|
||||
type StructuredResponseTimelineClient,
|
||||
} from '../src/commands/agent/run.ts'
|
||||
@@ -94,4 +95,32 @@ console.log('=== Run Output Schema Helper Tests ===\n')
|
||||
console.log('✓ returns null when timeline fetch throws')
|
||||
}
|
||||
|
||||
// Test 5: Provider/model slash syntax resolves both values.
|
||||
{
|
||||
const result = resolveProviderAndModel({ provider: 'codex/gpt-5.4' })
|
||||
assert.deepStrictEqual(result, {
|
||||
provider: 'codex',
|
||||
model: 'gpt-5.4',
|
||||
})
|
||||
console.log('✓ resolves provider/model slash syntax')
|
||||
}
|
||||
|
||||
// Test 6: Explicit matching --model coexists with slash syntax.
|
||||
{
|
||||
const result = resolveProviderAndModel({ provider: 'codex/gpt-5.4', model: 'gpt-5.4' })
|
||||
assert.deepStrictEqual(result, {
|
||||
provider: 'codex',
|
||||
model: 'gpt-5.4',
|
||||
})
|
||||
console.log('✓ accepts matching explicit model with slash syntax')
|
||||
}
|
||||
|
||||
// Test 7: Conflicting --model is rejected.
|
||||
{
|
||||
assert.throws(() => resolveProviderAndModel({ provider: 'codex/gpt-5.4', model: 'gpt-5.5' }), {
|
||||
message: 'Conflicting model values provided',
|
||||
})
|
||||
console.log('✓ rejects conflicting explicit model with slash syntax')
|
||||
}
|
||||
|
||||
console.log('\n=== All helper tests passed ===')
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env npx tsx
|
||||
|
||||
import assert from 'node:assert'
|
||||
import { resolveAgentId } from '../src/utils/client.js'
|
||||
|
||||
console.log('=== Agent ID Resolution Tests ===\n')
|
||||
|
||||
const agents = [
|
||||
{ id: 'abc1234-full-agent-id', title: 'Build docs' },
|
||||
{ id: 'def5678-other-agent-id', title: 'Fix archive flow' },
|
||||
{ id: '987zyxw-third-agent-id', title: 'Review PR' },
|
||||
]
|
||||
|
||||
{
|
||||
console.log('Test 1: exact ID match resolves')
|
||||
assert.strictEqual(resolveAgentId('abc1234-full-agent-id', agents), 'abc1234-full-agent-id')
|
||||
console.log('✓ exact ID match resolves\n')
|
||||
}
|
||||
|
||||
{
|
||||
console.log('Test 2: ID prefix resolves')
|
||||
assert.strictEqual(resolveAgentId('def5678', agents), 'def5678-other-agent-id')
|
||||
console.log('✓ ID prefix resolves\n')
|
||||
}
|
||||
|
||||
{
|
||||
console.log('Test 3: exact name match resolves case-insensitively')
|
||||
assert.strictEqual(resolveAgentId('fix archive flow', agents), 'def5678-other-agent-id')
|
||||
console.log('✓ exact name match resolves case-insensitively\n')
|
||||
}
|
||||
|
||||
{
|
||||
console.log('Test 4: partial name match resolves when unique')
|
||||
assert.strictEqual(resolveAgentId('review', agents), '987zyxw-third-agent-id')
|
||||
console.log('✓ partial name match resolves when unique\n')
|
||||
}
|
||||
|
||||
{
|
||||
console.log('Test 5: missing agent returns null')
|
||||
assert.strictEqual(resolveAgentId('does not exist', agents), null)
|
||||
console.log('✓ missing agent returns null\n')
|
||||
}
|
||||
|
||||
console.log('=== All agent ID resolution tests passed ===')
|
||||
Reference in New Issue
Block a user