@distri/core 0.2.4 → 0.2.7

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
@@ -137,4 +137,63 @@ const part: DistriPart = {
137
137
  code: 'console.log("Hello");'
138
138
  }
139
139
  };
140
- ```
140
+ ```
141
+
142
+ ## Session Store API
143
+
144
+ The `DistriClient` provides a comprehensive session store API for managing thread-scoped key-value storage.
145
+
146
+ ### Basic Operations
147
+
148
+ ```typescript
149
+ import { DistriClient } from '@distri/core';
150
+
151
+ const client = DistriClient.create();
152
+ const sessionId = 'thread-123';
153
+
154
+ // Set a session value
155
+ await client.setSessionValue(sessionId, 'key', { data: 'value' });
156
+
157
+ // Get a session value
158
+ const value = await client.getSessionValue(sessionId, 'key');
159
+
160
+ // Get all session values (returns a map)
161
+ const allValues = await client.getSessionValues(sessionId);
162
+
163
+ // Delete a session value
164
+ await client.deleteSessionValue(sessionId, 'key');
165
+
166
+ // Clear all session values
167
+ await client.clearSession(sessionId);
168
+ ```
169
+
170
+ ### API Endpoints
171
+
172
+ All session methods use the following endpoints (mounted at `/v1/sessions/`):
173
+
174
+ - `POST /sessions/{sessionId}/values` - Set a session value
175
+ - `GET /sessions/{sessionId}/values` - Get all session values (returns map)
176
+ - `GET /sessions/{sessionId}/values/{key}` - Get a specific session value
177
+ - `DELETE /sessions/{sessionId}/values/{key}` - Delete a session value
178
+ - `DELETE /sessions/{sessionId}` - Clear all session values
179
+
180
+ ### Integration with Agent Definitions
181
+
182
+ Session values can be referenced in agent definitions using `UserMessageOverrides`:
183
+
184
+ ```yaml
185
+ # Agent definition
186
+ user_message_overrides:
187
+ parts:
188
+ - type: session_key
189
+ key: "observation" # References session value with key "observation"
190
+ - type: template
191
+ template: "custom_user_template"
192
+ include_artifacts: true
193
+ ```
194
+
195
+ When the agent processes a message, it will automatically:
196
+ 1. Load all session values as a map
197
+ 2. Resolve `PartDefinition::SessionKey` references from the map
198
+ 3. Merge override parts with the default message parts
199
+ 4. Include the merged message in the LLM prompt