@hotmeshio/hotmesh 0.5.2 → 0.5.3

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
@@ -106,9 +106,9 @@ This index improves performance for filtered queries while reducing index size.
106
106
 
107
107
  ## Durable AI Agents
108
108
 
109
- Agents often require memory—context that persists between invocations, spans multiple perspectives, or outlives a single process. HotMesh supports that natively.
109
+ Agents often require memory—context that persists between invocations, spans multiple perspectives, or outlives a single process.
110
110
 
111
- The following example builds a "research agent" that runs sub-flows and self-reflects on the results.
111
+ The following example builds a "research agent" that executes hooks with different perspectives and then synthesizes. The data-first approach sets up initial state and then uses temporary hook functions to augment over the lifecycle of the entity record.
112
112
 
113
113
  ### Research Agent Example
114
114
 
@@ -116,56 +116,57 @@ The following example builds a "research agent" that runs sub-flows and self-ref
116
116
 
117
117
  ```ts
118
118
  export async function researchAgent(query: string): Promise<any> {
119
- const entity = await MemFlow.workflow.entity();
119
+ const agent = await MemFlow.workflow.entity();
120
120
 
121
121
  // Set up shared memory for this agent session
122
- await entity.set({
122
+ const initialState = {
123
123
  query,
124
124
  findings: [],
125
125
  perspectives: {},
126
126
  confidence: 0,
127
- status: 'researching'
128
- });
127
+ verification: {},
128
+ status: 'researching',
129
+ startTime: new Date().toISOString(),
130
+ }
131
+ await agent.set<typeof initialState>(initialState);
129
132
 
130
- // Launch perspective hooks in parallel (no need to await here)
131
- const optimistic = MemFlow.workflow.execHook({
133
+ // Launch perspective hooks in parallel
134
+ await MemFlow.workflow.execHook({
132
135
  taskQueue: 'agents',
133
136
  workflowName: 'optimisticPerspective',
134
- args: [query]
137
+ args: [query],
138
+ signalId: 'optimistic-complete'
135
139
  });
136
140
 
137
- const skeptical = MemFlow.workflow.execHook({
141
+ await MemFlow.workflow.execHook({
138
142
  taskQueue: 'agents',
139
143
  workflowName: 'skepticalPerspective',
140
- args: [query]
144
+ args: [query],
145
+ signalId: 'skeptical-complete'
141
146
  });
142
147
 
143
- // Launch a child workflow with its own isolated entity/state
144
- const factChecker = await MemFlow.workflow.execChild({
145
- entity: 'fact-checker',
146
- workflowName: 'factCheckAgent',
147
- workflowId: `fact-check-${Date.now()}`,
148
+ await MemFlow.workflow.execHook({
149
+ taskQueue: 'agents',
150
+ workflowName: 'verificationHook',
148
151
  args: [query],
149
- taskQueue: 'agents'
152
+ signalId: 'verification-complete'
150
153
  });
151
154
 
152
- // Wait for all views to complete before analyzing
153
- await Promise.all([optimistic, skeptical, factChecker]);
154
-
155
- // Final synthesis: aggregate and compare all perspectives
156
155
  await MemFlow.workflow.execHook({
157
156
  taskQueue: 'perspectives',
158
157
  workflowName: 'synthesizePerspectives',
159
- args: []
158
+ args: [],
159
+ signalId: 'synthesis-complete',
160
160
  });
161
161
 
162
- return await entity.get();
162
+ // return analysis, verification, and synthesis
163
+ return await agent.get();
163
164
  }
164
165
  ```
165
166
 
166
- > 💡 **Developer Note**: A complete implementation of this Research Agent example with tests, OpenAI integration, and multi-perspective analysis can be found in the [test suite](./tests/memflow/agent).
167
+ > 💡 A complete implementation of this Research Agent example with tests, OpenAI integration, and multi-perspective analysis can be found in the [agent test suite](https://github.com/hotmeshio/sdk-typescript/tree/main/tests/memflow/agent).
167
168
 
168
- #### Hooks: Perspectives
169
+ #### Perspective Hooks
169
170
 
170
171
  ```ts
171
172
  // Optimistic hook looks for affirming evidence
@@ -184,27 +185,11 @@ export async function skepticalPerspective(query: string, config: {signal: strin
184
185
  await entity.merge({ perspectives: { skeptical: { counterEvidence, confidence: 0.6 }}});
185
186
  await MemFlow.workflow.signal(config.signal, {});
186
187
  }
187
- ```
188
-
189
- #### Child Agent: Fact Checker
190
-
191
- ```ts
192
- // A dedicated child agent with its own entity type and context
193
- export async function factCheckAgent(query: string): Promise<any> {
194
- const entity = await MemFlow.workflow.entity();
195
- await entity.set({ query, sources: [], verifications: [] });
196
188
 
197
- await MemFlow.workflow.execHook({
198
- taskQueue: 'agents',
199
- workflowName: 'verifySourceCredibility',
200
- args: [query]
201
- });
202
-
203
- return await entity.get();
204
- }
189
+ // Other hooks...
205
190
  ```
206
191
 
207
- #### Synthesis
192
+ #### Synthesis Hook
208
193
 
209
194
  ```ts
210
195
  // Synthesis hook aggregates different viewpoints
@@ -231,7 +216,7 @@ export async function synthesizePerspectives(config: {signal: string}): Promise<
231
216
 
232
217
  ## Building Pipelines with State
233
218
 
234
- HotMesh treats pipelines as long-lived records, not ephemeral jobs. Every pipeline run is stateful, resumable, and traceable.
219
+ HotMesh treats pipelines as long-lived records. Every pipeline run is stateful, resumable, and traceable.
235
220
 
236
221
  ### Setup a Data Pipeline
237
222
 
@@ -357,7 +342,7 @@ export async function triggerRefresh() {
357
342
  }
358
343
  ```
359
344
 
360
- > 💡 **Developer Note**: A complete implementation of this Pipeline example with OpenAI Vision integration, processing hooks, and document workflow automation can be found in the [test suite](./tests/memflow/pipeline).
345
+ > 💡 A complete implementation of this Pipeline example with OpenAI Vision integration, processing hooks, and document workflow automation can be found in the [pipeline test suite](https://github.com/hotmeshio/sdk-typescript/tree/main/tests/memflow/pipeline).
361
346
 
362
347
  ---
363
348
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Permanent-Memory Workflows & AI Agents",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Permanent-Memory Workflows & AI Agents",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",