mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-13 07:55:09 -05:00
feat(a2a): added a2a protocol (#2784)
* feat(a2a): a2a added * feat(a2a): added a2a protocol * remove migrations * readd migrations * consolidated permissions utils * consolidated tag-input, output select -> combobox, added tags for A2A * cleanup up utils, share same deployed state as other tabs * ack PR comments * more * updated code examples * solely rely on tanstack query to vend data and invalidate query key's, remove custom caching --------- Co-authored-by: Emir Karabeg <emirkarabeg@berkeley.edu>
This commit is contained in:
33
apps/sim/background/a2a-push-notification-delivery.ts
Normal file
33
apps/sim/background/a2a-push-notification-delivery.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { TaskState } from '@a2a-js/sdk'
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { task } from '@trigger.dev/sdk'
|
||||
import { deliverPushNotification } from '@/lib/a2a/push-notifications'
|
||||
|
||||
const logger = createLogger('A2APushNotificationDelivery')
|
||||
|
||||
export interface A2APushNotificationParams {
|
||||
taskId: string
|
||||
state: TaskState
|
||||
}
|
||||
|
||||
export const a2aPushNotificationTask = task({
|
||||
id: 'a2a-push-notification-delivery',
|
||||
retry: {
|
||||
maxAttempts: 5,
|
||||
minTimeoutInMs: 1000,
|
||||
maxTimeoutInMs: 60000,
|
||||
factor: 2,
|
||||
},
|
||||
run: async (params: A2APushNotificationParams) => {
|
||||
logger.info('Delivering A2A push notification', params)
|
||||
|
||||
const success = await deliverPushNotification(params.taskId, params.state)
|
||||
|
||||
if (!success) {
|
||||
throw new Error(`Failed to deliver push notification for task ${params.taskId}`)
|
||||
}
|
||||
|
||||
logger.info('A2A push notification delivered successfully', params)
|
||||
return { success: true, taskId: params.taskId, state: params.state }
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user