SDK
Device Agent SDK
Build a custom device agent for any platform using the DeviceAgentAdapter interface.
my-custom-agent.ts
| 1 | // Implement the DeviceAgentAdapter interface |
| 2 | import type { DeviceAgentAdapter } from '@tee/core/actions/adapters/DeviceAgentAdapter'; |
| 3 | import type { ActionResult, ActionType } from '@tee/types/tee'; |
| 4 | |
| 5 | export class MyCustomAgent implements DeviceAgentAdapter { |
| 6 | readonly deviceType = 'terminal' as const; |
| 7 | |
| 8 | async executeAction( |
| 9 | action: { actionType: ActionType; parameters: Record |
| 10 | _deviceInfo: unknown, |
| 11 | _userId: string, |
| 12 | ): Promise |
| 13 | switch (action.actionType) { |
| 14 | case 'RunScript': { |
| 15 | const { script } = action.parameters as { script: string }; |
| 16 | // Run script in a sandboxed environment (e.g. isolated-vm) in production. |
| 17 | return { id: crypto.randomUUID(), actionId: crypto.randomUUID(), |
| 18 | status: 'success', details: 'Script executed', completedAt: new Date().toISOString() }; |
| 19 | } |
| 20 | default: |
| 21 | return { id: crypto.randomUUID(), actionId: crypto.randomUUID(), |
| 22 | status: 'blocked', details: `Action ${action.actionType} not supported` }; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | async healthCheck(): Promise |
| 27 | return true; |
| 28 | } |
| 29 | } |