Skip to content
Merged
52 changes: 34 additions & 18 deletions apps/docs/content/docs/integrations/polymarket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,15 @@ Retrieve user positions from Polymarket
| `user` | string | Yes | User wallet address |
| `market` | string | No | Condition IDs to filter positions \(e.g., "0x1234...abcd,0x5678...efgh"\). Mutually exclusive with eventId. |
| `eventId` | string | No | Event ID to filter positions \(e.g., "12345"\). Mutually exclusive with market. |
| `sizeThreshold` | string | No | Minimum position size threshold \(default: 1\) |
| `redeemable` | string | No | Filter for redeemable positions only \(true/false\) |
| `mergeable` | string | No | Filter for mergeable positions only \(true/false\) |
| `sortBy` | string | No | Sort field \(TOKENS, CURRENT, INITIAL, CASHPNL, PERCENTPNL, TITLE, RESOLVING, PRICE, AVGPRICE\) |
| `sizeThreshold` | string | No | Minimum current position size in shares \(default: 0.1\) |
| `redeemable` | string | No | true: only redeemable positions. false: drops redeemable positions from the returned page. |
| `mergeable` | string | No | true: only mergeable positions. false: drops mergeable positions from the returned page. |
| `sortBy` | string | No | Sort field: CURRENT_VALUE \(default\), TOKENS, PRICE, UNREALIZED_PNL, REALIZED_PNL, TOTAL_PNL, or TIMESTAMP |
| `sortDirection` | string | No | Sort direction \(ASC or DESC\) |
| `title` | string | No | Search filter by title |
| `limit` | string | No | Number of results per page \(e.g., "25"\). |
| `offset` | string | No | Number of results to skip for pagination \(e.g., "50"\). |
| `limit` | string | No | Number of results for the first page \(e.g., "25"\). Max: 1000. |
| `offset` | string | No | Not supported by the Polymarket Data API v2, which pages by cursor. Use cursor instead. |
| `cursor` | string | No | Pagination cursor: the nextCursor from the previous page's output. Resend the same filters with it. |

#### Output

Expand Down Expand Up @@ -530,6 +531,9 @@ Retrieve user positions from Polymarket
| ↳ `oppositeAsset` | string | Opposite asset token ID |
| ↳ `endDate` | string | End date |
| ↳ `negativeRisk` | boolean | Whether negative risk |
| ↳ `status` | string | Position state \(OPEN, REDEEMABLE, REDEEMABLE_LOST, MERGEABLE, CLOSED\) |
| `nextCursor` | string | Cursor for the next page; pass it as Cursor. Null on the last page. |
| `hasMore` | boolean | Whether another page exists |

</ReferenceDetails>

Expand All @@ -550,8 +554,9 @@ Retrieve trade history from Polymarket
| `takerOnly` | string | No | Filter for taker trades only \(true/false, default: true\) |
| `filterType` | string | No | Filter type \(CASH or TOKENS\) - requires filterAmount |
| `filterAmount` | string | No | Filter amount threshold - requires filterType |
| `limit` | string | No | Number of results per page \(e.g., "50"\). Default: 100, max: 10000. |
| `offset` | string | No | Number of results to skip for pagination \(e.g., "100"\). |
| `limit` | string | No | Number of results for the first page \(e.g., "50"\). Default: 100, max: 1000. |
| `offset` | string | No | Not supported by the Polymarket Data API v2, which pages by cursor. Use cursor instead. |
| `cursor` | string | No | Pagination cursor: the nextCursor from the previous page's output. Resend the same filters with it. |

#### Output

Expand All @@ -577,6 +582,8 @@ Retrieve trade history from Polymarket
| ↳ `profileImage` | string | Profile image URL |
| ↳ `profileImageOptimized` | string | Optimized profile image URL |
| ↳ `transactionHash` | string | Transaction hash |
| `nextCursor` | string | Cursor for the next page; pass it as Cursor. Null on the last page. |
| `hasMore` | boolean | Whether another page exists |

</ReferenceDetails>

Expand All @@ -591,16 +598,17 @@ Retrieve on-chain activity for a user including trades, splits, merges, redempti
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `user` | string | Yes | User wallet address \(0x-prefixed\) |
| `limit` | string | No | Maximum results to return \(e.g., "50"\). Default: 100, max: 500. |
| `offset` | string | No | Number of results to skip for pagination \(e.g., "100"\). Default: 0, max: 10000. |
| `limit` | string | No | Number of results for the first page \(e.g., "50"\). Default: 100, max: 1000. |
| `offset` | string | No | Not supported by the Polymarket Data API v2, which pages by cursor. Use cursor instead. |
| `market` | string | No | Comma-separated condition IDs \(e.g., "0x1234...abcd,0x5678...efgh"\). Mutually exclusive with eventId. |
| `eventId` | string | No | Comma-separated event IDs \(e.g., "12345,67890"\). Mutually exclusive with market. |
| `type` | string | No | Activity type filter: TRADE, SPLIT, MERGE, REDEEM, REWARD, CONVERSION, MAKER_REBATE, REFERRAL_REWARD |
| `start` | number | No | Start timestamp \(Unix seconds\) |
| `end` | number | No | End timestamp \(Unix seconds\) |
| `sortBy` | string | No | Sort field: TIMESTAMP, TOKENS, or CASH \(default: TIMESTAMP\) |
| `sortBy` | string | No | Sort field. Polymarket supports only TIMESTAMP. |
| `sortDirection` | string | No | Sort direction: ASC or DESC \(default: DESC\) |
| `side` | string | No | Trade side filter: BUY or SELL \(only applies to trades\) |
| `cursor` | string | No | Pagination cursor: the nextCursor from the previous page's output. Resend the same filters with it. |

#### Output

Expand Down Expand Up @@ -628,6 +636,8 @@ Retrieve on-chain activity for a user including trades, splits, merges, redempti
| ↳ `bio` | string | User bio |
| ↳ `profileImage` | string | User profile image URL |
| ↳ `profileImageOptimized` | string | Optimized profile image URL |
| `nextCursor` | string | Cursor for the next page; pass it as Cursor. Null on the last page. |
| `hasMore` | boolean | Whether another page exists |

</ReferenceDetails>

Expand All @@ -643,11 +653,12 @@ Retrieve trader leaderboard rankings by profit/loss or volume
| --------- | ---- | -------- | ----------- |
| `category` | string | No | Category filter: OVERALL, POLITICS, SPORTS, CRYPTO, CULTURE, MENTIONS, WEATHER, ECONOMICS, TECH, FINANCE \(default: OVERALL\) |
| `timePeriod` | string | No | Time period: DAY, WEEK, MONTH, ALL \(default: DAY\) |
| `orderBy` | string | No | Order by: PNL or VOL \(default: PNL\) |
| `limit` | string | No | Number of results to return \(e.g., "10"\). Range: 1-50, default: 25. |
| `offset` | string | No | Number of results to skip for pagination \(e.g., "25"\). Range: 0-1000, default: 0. |
| `user` | string | No | Filter by specific user wallet address |
| `userName` | string | No | Filter by username |
| `orderBy` | string | No | Order by: PNL or VOLUME \(default: PNL\) |
| `limit` | string | No | Number of results for the first page \(e.g., "10"\). Max: 1000. |
| `offset` | string | No | Not supported by the Polymarket Data API v2, which pages by cursor. Use cursor instead. |
| `user` | string | No | Wallet address to look up that user's rank instead of the board |
| `userName` | string | No | Not supported by the Polymarket Data API v2. Use user with a wallet address instead. |
| `cursor` | string | No | Pagination cursor: the nextCursor from the previous page's output. Resend the same filters with it. |

#### Output

Expand All @@ -662,6 +673,8 @@ Retrieve trader leaderboard rankings by profit/loss or volume
| ↳ `profileImage` | string | User profile image URL |
| ↳ `xUsername` | string | Twitter/X username |
| ↳ `verifiedBadge` | boolean | Whether user has verified badge |
| `nextCursor` | string | Cursor for the next page; pass it as Cursor. Null on the last page. |
| `hasMore` | boolean | Whether another page exists |

</ReferenceDetails>

Expand All @@ -676,8 +689,9 @@ Retrieve top holders of a specific market token
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `market` | string | Yes | Comma-separated list of condition IDs \(e.g., "0x1234...abcd" or "0x1234...abcd,0x5678...efgh"\). |
| `limit` | string | No | Number of holders to return \(e.g., "10"\). Range: 0-20, default: 20. |
| `minBalance` | string | No | Minimum balance threshold \(default: 1\) |
| `limit` | string | No | Number of holders per outcome token \(e.g., "10"\). Default: 100, max: 1000. |
| `minBalance` | string | No | Minimum net balance in shares \(default: 0\) |
| `cursor` | string | No | Pagination cursor: the nextCursor from the previous page's output. Resend the same filters with it. |

#### Output

Expand All @@ -697,6 +711,8 @@ Retrieve top holders of a specific market token
| ↳ `profileImage` | string | Profile image URL |
| ↳ `profileImageOptimized` | string | Optimized profile image URL |
| ↳ `verified` | boolean | Whether the holder is verified |
| `nextCursor` | string | Cursor for the next page; pass it as Cursor. Null on the last page. |
| `hasMore` | boolean | Whether another page exists |

</ReferenceDetails>

Expand Down
30 changes: 30 additions & 0 deletions apps/sim/blocks/blocks/jupyter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vitest'
import { JupyterBlock } from '@/blocks/blocks/jupyter'

const SERVER = { serverUrl: 'https://jupyter.example.com', token: 'token' }

/** The executor sends `{ ...storedInputs, ...mapped }`, so a value stored for another operation must not leak in. */
describe('Jupyter block Create Session', () => {
it('does not send the Create File type as the session type', () => {
const stored = {
...SERVER,
operation: 'jupyter_create_session',
path: 'analysis.ipynb',
type: 'file',
}
expect(
{ ...stored, ...JupyterBlock.tools.config.params(stored, undefined) }.type
).toBeUndefined()
})

it('sends the Session Type field, or the model type on an agent tool call', () => {
const stored = { ...SERVER, operation: 'jupyter_create_session', sessionType: 'console' }
expect(JupyterBlock.tools.config.params(stored, undefined).type).toBe('console')
expect(
JupyterBlock.tools.config.params(
{ ...SERVER, path: 'a.ipynb', type: 'console' },
{ operation: 'jupyter_create_session' }
).type
).toBe('console')
})
})
3 changes: 2 additions & 1 deletion apps/sim/blocks/blocks/jupyter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createVersionedToolSelector,
mapperOperation,
normalizeFileInput,
toolCallArg,
withSavedCredential,
} from '@/blocks/utils'

Expand Down Expand Up @@ -342,7 +343,7 @@ export const JupyterBlock = {
baseParams.path = params.path
if (params.kernelName) baseParams.kernelName = params.kernelName
if (params.sessionName) baseParams.name = params.sessionName
if (params.sessionType) baseParams.type = params.sessionType
baseParams.type = params.sessionType || toolCallArg(context, params.type)
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
break
case 'jupyter_delete_session':
baseParams.sessionId = params.sessionId
Expand Down
39 changes: 39 additions & 0 deletions apps/sim/blocks/blocks/kalshi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,42 @@ describe('KalshiBlock', () => {
expect({ ...args, ...buildParams(args, { operation: 'cancel_order' }) }.orderId).toBe('model')
})
})

/** The executor sends `{ ...storedInputs, ...mapped }`, so a value stored for another operation must not leak in. */
describe('KalshiBlock fields owned by one operation', () => {
const stored = {
minTs: '1700000000',
maxTs: '1700003600',
countFp: '10.00',
ticker: 'KXOLD-24',
countAmend: '5',
orderIdParam: 'order-1',
tickerOrder: 'KXNEW-25',
}
const run = (operation: string) => {
const inputs = { ...stored, operation }
return { ...inputs, ...KalshiBlock.tools.config?.params?.(inputs) }
}

it('does not apply the Get Fills time window to Get Orders, Get Trades or Get Settlements', () => {
for (const operation of ['get_orders', 'get_trades', 'get_settlements']) {
expect(run(operation)).toMatchObject({ minTs: undefined, maxTs: undefined })
}
expect(run('get_fills')).toMatchObject({ minTs: '1700000000', maxTs: '1700003600' })
})

it('does not send the Create Order fixed-point count when amending an order', () => {
expect(run('amend_order')).toMatchObject({ count: '5', countFp: undefined })
})

it('does not filter Get Trades by the Get Market ticker', () => {
expect(run('get_trades').ticker).toBeUndefined()
})

it('keeps the model time window and ticker on an agent tool call', () => {
const args = { minTs: '1', maxTs: '2', ticker: 'KX-1' }
expect(KalshiBlock.tools.config?.params?.(args, { operation: 'get_trades' })).toMatchObject(
args
)
})
})
13 changes: 12 additions & 1 deletion apps/sim/blocks/blocks/kalshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const KalshiBlock: BlockConfig = {
{ label: 'Get Series List', id: 'get_series_list' },
{ label: 'Get Exchange Status', id: 'get_exchange_status' },
{ label: 'Get Exchange Schedule', id: 'get_exchange_schedule' },
{ label: 'Get Exchange Announcements', id: 'get_exchange_announcements' },
{ label: 'Get Exchange Announcements', id: 'get_exchange_announcements', hidden: true },
{ label: 'Create Order', id: 'create_order' },
{ label: 'Cancel Order', id: 'cancel_order' },
{ label: 'Amend Order', id: 'amend_order' },
Expand Down Expand Up @@ -732,6 +732,17 @@ Return ONLY the numeric timestamp (seconds since Unix epoch) - no explanations,
cleanParams[key] = field || toolCallArg(context, cleanParams[key])
}

/** Fields shown only for one operation: any other operation takes them from the model alone. */
const keepOnlyFor = (key: string, owner: string) => {
if (operation !== owner) cleanParams[key] = toolCallArg(context, cleanParams[key])
}
keepOnlyFor('minTs', 'get_fills')
keepOnlyFor('maxTs', 'get_fills')
keepOnlyFor('countFp', 'create_order')
if (operation === 'get_trades') {
cleanParams.ticker = toolCallArg(context, cleanParams.ticker)
}

if (operation === 'get_orders') {
mapField('status', orderStatus)
}
Expand Down
38 changes: 31 additions & 7 deletions apps/sim/blocks/blocks/polymarket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,15 @@ export const PolymarketBlock: BlockConfig = {
{ label: 'Default', id: '' },
{ label: 'Tokens', id: 'TOKENS' },
{ label: 'Current Value', id: 'CURRENT' },
{ label: 'Initial Value', id: 'INITIAL' },
{ label: 'Initial Value', id: 'INITIAL', hidden: true },
{ label: 'Cash P&L', id: 'CASHPNL' },
{ label: 'Percent P&L', id: 'PERCENTPNL' },
{ label: 'Title', id: 'TITLE' },
{ label: 'Realized P&L', id: 'REALIZED_PNL' },
{ label: 'Total P&L', id: 'TOTAL_PNL' },
{ label: 'Percent P&L', id: 'PERCENTPNL', hidden: true },
{ label: 'Title', id: 'TITLE', hidden: true },
{ label: 'Price', id: 'PRICE' },
{ label: 'Avg Price', id: 'AVGPRICE' },
{ label: 'Avg Price', id: 'AVGPRICE', hidden: true },
{ label: 'Last Activity', id: 'TIMESTAMP' },
],
condition: { field: 'operation', value: ['get_positions'] },
mode: 'advanced',
Expand Down Expand Up @@ -372,8 +375,8 @@ export const PolymarketBlock: BlockConfig = {
type: 'dropdown',
options: [
{ label: 'Timestamp', id: 'TIMESTAMP' },
{ label: 'Tokens', id: 'TOKENS' },
{ label: 'Cash', id: 'CASH' },
{ label: 'Tokens', id: 'TOKENS', hidden: true },
{ label: 'Cash', id: 'CASH', hidden: true },
],
condition: { field: 'operation', value: ['get_activity'] },
mode: 'advanced',
Expand Down Expand Up @@ -452,7 +455,7 @@ export const PolymarketBlock: BlockConfig = {
id: 'leaderboardUser',
title: 'User Address',
type: 'short-input',
placeholder: 'Filter by specific user wallet',
placeholder: "Look up one wallet's rank",
condition: { field: 'operation', value: ['get_leaderboard'] },
mode: 'advanced',
},
Expand Down Expand Up @@ -679,6 +682,17 @@ Return ONLY the Unix timestamp as a number - no explanations, no quotes, no extr
},
mode: 'advanced',
},
{
id: 'cursor',
title: 'Cursor',
type: 'short-input',
placeholder: 'nextCursor from the previous page',
condition: {
field: 'operation',
value: ['get_trades', 'get_positions', 'get_activity', 'get_leaderboard', 'get_holders'],
},
mode: 'advanced',
},
{
id: 'page',
title: 'Page',
Expand Down Expand Up @@ -944,6 +958,16 @@ Return ONLY the Unix timestamp as a number - no explanations, no quotes, no extr
activity: { type: 'json', description: 'Array of user activity entries (get_activity)' },
leaderboard: { type: 'json', description: 'Array of leaderboard entries (get_leaderboard)' },
holders: { type: 'json', description: 'Array of market holder groups (get_holders)' },
nextCursor: {
type: 'string',
description:
'Cursor for the next page (get_trades, get_positions, get_activity, get_leaderboard, get_holders)',
},
hasMore: {
type: 'boolean',
description:
'Whether another page exists (get_trades, get_positions, get_activity, get_leaderboard, get_holders)',
},
},
}

Expand Down
48 changes: 48 additions & 0 deletions apps/sim/blocks/blocks/sftp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,51 @@ describe('SftpV2Block agent tool calls', () => {
}).toMatchObject({ recursive: false })
})
})

/** The executor sends `{ ...storedInputs, ...mapped }`, so a value stored for another operation must not leak in. */
describe('SftpV2Block canvas runs', () => {
const stored = {
host: 'h',
username: 'u',
password: 'p',
remotePath: '/upload',
files: [{ name: 'report.csv', key: 'k', url: 'u', size: 1, type: 'text/csv' }],
fileContent: 'stale content',
fileName: 'stale.txt',
}
const run = (operation: string) => {
const inputs = { ...stored, operation }
return { ...inputs, ...SftpV2Block.tools.config?.params?.(inputs) }
}

it('does not write the Create File content on an Upload Files run', () => {
expect(run('sftp_upload')).toMatchObject({ fileContent: undefined, fileName: undefined })
})

it('does not upload the Upload Files files on a Create File run', () => {
expect(run('sftp_create')).toMatchObject({ files: undefined, fileName: 'stale.txt' })
})

it('keeps direct content the model sends on an upload tool call', () => {
const args = { host: 'h', username: 'u', password: 'p', remotePath: '/a' }
expect(
SftpV2Block.tools.config?.params?.(
{ ...args, fileContent: 'hi', fileName: 'a.txt' },
{ operation: 'sftp_upload' }
)
).toMatchObject({ fileContent: 'hi', fileName: 'a.txt' })
})

it('does not send a stored private key once the block is switched to password auth', () => {
const inputs = {
...stored,
operation: 'sftp_list',
authMethod: 'password',
privateKey: 'stale key',
}
expect({ ...inputs, ...SftpV2Block.tools.config?.params?.(inputs) }).toMatchObject({
password: 'p',
privateKey: undefined,
})
})
})
Loading
Loading