Skip to content

Commit d3993ce

Browse files
committed
fix: honor explicit zero argument count
1 parent a0665d9 commit d3993ce

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

packages/devframe/src/__tests__/tool-input.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ describe('tool input positional arguments', () => {
55
it('passes arrays through and maps argN keys using the declared count', () => {
66
expect(toolInputToRpcArgs([1, 2], 2)).toEqual([1, 2])
77
expect(toolInputToRpcArgs({ arg0: 'a', arg1: 'b' }, 2)).toEqual(['a', 'b'])
8+
expect(toolInputToRpcArgs({ arg0: 'a' }, 0)).toEqual([])
89
})
910

1011
it('collects contiguous argN keys without a declared count', () => {

packages/devframe/src/tool-input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function collectPositionalArgs(input: unknown, argumentCount: number | undefined
1313
return undefined
1414

1515
const record = input as Record<string, unknown>
16-
if (argumentCount)
16+
if (argumentCount != null)
1717
return Array.from({ length: argumentCount }, (_, index) => record[`arg${index}`])
1818
if ('arg0' in record) {
1919
const positional: unknown[] = []

0 commit comments

Comments
 (0)