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 39;@tee/core/actions/adapters/DeviceAgentAdapter39;; |
| 3 | import type { ActionResult, ActionType } from 39;@tee/types/tee39;; |
| 4 | |
| 5 | export class MyCustomAgent implements DeviceAgentAdapter { |
| 6 | readonly deviceType = 39;terminal39; as const; |
| 7 | |
| 8 | async executeAction( |
| 9 | action: { actionType: ActionType; parameters: Record<string, unknown> }, |
| 10 | _deviceInfo: unknown, |
| 11 | _userId: string, |
| 12 | ): Promise<ActionResult> { |
| 13 | switch (action.actionType) { |
| 14 | case 39;RunScript39;: { |
| 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: 39;success39;, details: 39;Script executed39;, completedAt: new Date().toISOString() }; |
| 19 | } |
| 20 | default: |
| 21 | return { id: crypto.randomUUID(), actionId: crypto.randomUUID(), |
| 22 | status: 39;blocked39;, details: `Action ${action.actionType} not supported` }; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | async healthCheck(): Promise<boolean> { |
| 27 | return true; |
| 28 | } |
| 29 | } |