Skip to main content

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
2import type { DeviceAgentAdapter } from '@tee/core/actions/adapters/DeviceAgentAdapter';
3import type { ActionResult, ActionType } from '@tee/types/tee';
4
5export class MyCustomAgent implements DeviceAgentAdapter {
6 readonly deviceType = 'terminal' 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;RunScript&#39;: {
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;success&#39;, details: &#39;Script executed&#39;, completedAt: new Date().toISOString() };
19 }
20 default:
21 return { id: crypto.randomUUID(), actionId: crypto.randomUUID(),
22 status: &#39;blocked&#39;, details: `Action ${action.actionType} not supported` };
23 }
24 }
25
26 async healthCheck(): Promise<boolean> {
27 return true;
28 }
29}