@elizaos/plugin-tee 1.0.0-alpha.7 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,7 @@ As Eliza is a fully autonomous AI agent capable of running within a TEE, we need
9
9
  ## Requirements
10
10
 
11
11
  Since the TEE Logging is based on the TEE, it is necessary to have a TEE enabled environment. Currently, we support Intel SGX (Gramine) and Intel TDX (dstack).
12
+
12
13
  - using Intel SGX (Gramine), you need to enable the plugin-sgx in the Eliza runtime, which is enabled in SGX env automatically.
13
14
  - using Intel TDX (dstack), you need to enable the plugin-tee in the Eliza runtime.
14
15
 
@@ -17,9 +18,11 @@ Since the TEE Logging is based on the TEE, it is necessary to have a TEE enabled
17
18
  ## TEE Logging Mechanism
18
19
 
19
20
  1. **Key Pair Generation and Attestation**:
21
+
20
22
  - During startup, each agent generates a key pair and creates a remote attestation for the public key. The private key is securely stored in the TEE's encrypted memory. The agent's relevant information, along with the public key and attestation, is recorded in a local database. A new key pair is generated each time the agent is updated or restarted to ensure key security.
21
23
 
22
24
  2. **Log Recording**:
25
+
23
26
  - For each log entry, basic information is recorded, including `agentId`, `roomId`, `userId`, `type`, `content`, and `timestamp`. This information is concatenated and signed using the agent's corresponding private key to ensure verifiability. The verification process follows this trust chain:
24
27
  - Verify the attestation.
25
28
  - Trust the public key contained in the attestation.
@@ -27,9 +30,11 @@ Since the TEE Logging is based on the TEE, it is necessary to have a TEE enabled
27
30
  - Trust the complete log record.
28
31
 
29
32
  3. **Data Storage**:
33
+
30
34
  - All log data must be stored in the TEE's encrypted file system in production environments. Storing data in plaintext is prohibited to prevent tampering.
31
35
 
32
36
  4. **Log Extraction for Verification**:
37
+
33
38
  - Third parties can extract TEE logs for verification purposes. Two types of information can be extracted:
34
39
  - **Agent Information**: This includes the agent's metadata, public key, and attestation, which can be used to verify the agent's public key.
35
40
  - **Log Information**: Required logs can be extracted, with the agent's attestation and public key used to verify the signature, ensuring that each record remains untampered.
@@ -48,24 +53,31 @@ The `TeeLogService` class implements the `ITeeLogService` interface and extends
48
53
  #### Methods
49
54
 
50
55
  - **getInstance()**: `TeeLogService`
56
+
51
57
  - Returns the singleton instance of the `TeeLogService`.
52
58
 
53
59
  - **static get serviceType()**: `ServiceType`
60
+
54
61
  - Returns the service type for TEE logging.
55
62
 
56
63
  - **async initialize(runtime: IAgentRuntime): Promise<void>**
64
+
57
65
  - Initializes the TEE log service. It checks the runtime settings to configure the TEE type and enables logging if configured.
58
66
 
59
67
  - **async log(agentId: string, roomId: string, userId: string, type: string, content: string): Promise<boolean>**
68
+
60
69
  - Logs an interaction with the specified parameters. Returns `false` if TEE logging is not enabled.
61
70
 
62
71
  - **async getAllAgents(): Promise<TeeAgent[]>**
72
+
63
73
  - Retrieves all agents that have been logged. Returns an empty array if TEE logging is not enabled.
64
74
 
65
75
  - **async getAgent(agentId: string): Promise<TeeAgent | undefined>**
76
+
66
77
  - Retrieves the details of a specific agent by their ID. Returns `undefined` if TEE logging is not enabled.
67
78
 
68
79
  - **async getLogs(query: TeeLogQuery, page: number, pageSize: number): Promise<PageQuery<TeeLog[]>>**
80
+
69
81
  - Retrieves logs based on the provided query parameters. Returns an empty result if TEE logging is not enabled.
70
82
 
71
83
  - **async generateAttestation(userReport: string): Promise<string>**
@@ -98,39 +110,34 @@ First, add plugin-tee-log to the dependencies of plugin-bootstrap:
98
110
  Then, add the following code to the `Continue` action:
99
111
 
100
112
  ```typescript
101
- import {
102
- ServiceType,
103
- ITeeLogService,
104
- } from "@elizaos/core";
105
-
113
+ import { ServiceType, ITeeLogService } from '@elizaos/core';
106
114
 
107
115
  // In the handler of the action
108
- handler: async (
109
- runtime: IAgentRuntime,
110
- message: Memory,
111
- state: State,
112
- options: any,
113
- callback: HandlerCallback
114
- ) => {
115
- // Continue the action
116
-
117
- // Log the action
118
- const teeLogService = runtime
119
- .getService<ITeeLogService>(ServiceType.TEE_LOG)
120
- .getInstance();
121
- if (teeLogService.log(
122
- runtime.agentId,
123
- message.roomId,
124
- message.userId,
125
- "The type of the log, for example, Action:CONTINUE",
126
- "The content that you want to log"
127
- )
128
- ) {
129
- console.log("Logged TEE log successfully");
130
- }
131
-
132
- // Continue the action
133
- }
116
+ handler: async (
117
+ runtime: IAgentRuntime,
118
+ message: Memory,
119
+ state: State,
120
+ options: any,
121
+ callback: HandlerCallback
122
+ ) => {
123
+ // Continue the action
124
+
125
+ // Log the action
126
+ const teeLogService = runtime.getService<ITeeLogService>(ServiceType.TEE_LOG).getInstance();
127
+ if (
128
+ teeLogService.log(
129
+ runtime.agentId,
130
+ message.roomId,
131
+ message.userId,
132
+ 'The type of the log, for example, Action:CONTINUE',
133
+ 'The content that you want to log'
134
+ )
135
+ ) {
136
+ console.log('Logged TEE log successfully');
137
+ }
138
+
139
+ // Continue the action
140
+ };
134
141
  ```
135
142
 
136
- After configuring the logging for the action, you can run the Eliza and see the logs through the client-direct REST API. See more details in the [Client-Direct REST API](../client-direct/src/README.md) documentation.
143
+ After configuring the logging for the action, you can run the Eliza and see the logs through the client-direct REST API. See more details in the [Client-Direct REST API](../client-direct/src/README.md) documentation.
@@ -3,8 +3,7 @@ import {
3
3
  offchainLookup,
4
4
  offchainLookupAbiItem,
5
5
  offchainLookupSignature
6
- } from "./chunk-KOK2JF4L.js";
7
- import "./chunk-672HY72Z.js";
6
+ } from "./chunk-BKMXH7YA.js";
8
7
  import "./chunk-PR4QN5HX.js";
9
8
  export {
10
9
  ccipRequest,
@@ -12,4 +11,4 @@ export {
12
11
  offchainLookupAbiItem,
13
12
  offchainLookupSignature
14
13
  };
15
- //# sourceMappingURL=ccip-I2SBJWHH.js.map
14
+ //# sourceMappingURL=ccip-FJGACAMU.js.map
@@ -0,0 +1,14 @@
1
+ import {
2
+ ccipRequest,
3
+ offchainLookup,
4
+ offchainLookupAbiItem,
5
+ offchainLookupSignature
6
+ } from "./chunk-I5LRTHFY.js";
7
+ import "./chunk-PR4QN5HX.js";
8
+ export {
9
+ ccipRequest,
10
+ offchainLookup,
11
+ offchainLookupAbiItem,
12
+ offchainLookupSignature
13
+ };
14
+ //# sourceMappingURL=ccip-RMYIHBNG.js.map