@hotmeshio/hotmesh 0.4.1 → 0.4.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.
Files changed (38) hide show
  1. package/README.md +114 -51
  2. package/build/index.d.ts +2 -1
  3. package/build/index.js +3 -1
  4. package/build/package.json +3 -2
  5. package/build/services/activities/trigger.d.ts +1 -1
  6. package/build/services/activities/trigger.js +3 -3
  7. package/build/services/memflow/client.js +2 -1
  8. package/build/services/memflow/{context.d.ts → entity.d.ts} +34 -34
  9. package/build/services/memflow/{context.js → entity.js} +40 -40
  10. package/build/services/memflow/index.d.ts +2 -2
  11. package/build/services/memflow/index.js +2 -2
  12. package/build/services/memflow/workflow/common.d.ts +2 -2
  13. package/build/services/memflow/workflow/common.js +3 -3
  14. package/build/services/memflow/workflow/entityMethods.d.ts +14 -0
  15. package/build/services/memflow/workflow/{contextMethods.js → entityMethods.js} +11 -11
  16. package/build/services/memflow/workflow/index.d.ts +2 -2
  17. package/build/services/memflow/workflow/index.js +2 -2
  18. package/build/services/memflow/workflow/signal.d.ts +23 -1
  19. package/build/services/memflow/workflow/signal.js +23 -1
  20. package/build/services/memflow/workflow/sleepFor.d.ts +17 -1
  21. package/build/services/memflow/workflow/sleepFor.js +17 -1
  22. package/build/services/memflow/workflow/waitFor.d.ts +22 -1
  23. package/build/services/memflow/workflow/waitFor.js +22 -1
  24. package/build/services/store/index.d.ts +1 -1
  25. package/build/services/store/providers/postgres/kvsql.d.ts +1 -1
  26. package/build/services/store/providers/postgres/kvtypes/hash.d.ts +1 -1
  27. package/build/services/store/providers/postgres/kvtypes/hash.js +8 -8
  28. package/build/services/store/providers/postgres/postgres.d.ts +34 -1
  29. package/build/services/store/providers/postgres/postgres.js +211 -2
  30. package/build/services/store/providers/redis/_base.d.ts +1 -1
  31. package/build/services/store/providers/redis/_base.js +1 -1
  32. package/build/services/task/index.d.ts +12 -0
  33. package/build/services/task/index.js +47 -0
  34. package/build/types/job.d.ts +7 -0
  35. package/build/types/provider.d.ts +1 -0
  36. package/index.ts +2 -2
  37. package/package.json +4 -3
  38. package/build/services/memflow/workflow/contextMethods.d.ts +0 -14
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
- # HotMesh MemFlow
1
+ # HotMesh
2
2
 
3
3
  **Permanent-Memory Workflows & AI Agents**
4
4
 
5
5
  ![beta release](https://img.shields.io/badge/release-beta-blue.svg) ![made with typescript](https://img.shields.io/badge/built%20with-typescript-lightblue.svg)
6
6
 
7
- MemFlow is a drop-in Temporal-style engine that runs natively on Postgresbut with a twist:
8
- every workflow owns a *permanent*, JSON-backed context that lives beyond the main workflow.
9
- Any number of *hooks* (lightweight, thread-safe workers) can attach to that record at any
10
- time, read it, and safely write back incremental knowledge.
11
- Think **durable execution** + **shared, evolving memory** perfect for human-in-the-loop
12
- processes and AI agents that learn over time.
7
+ **HotMesh** is a Temporal-style workflow engine that runs natively on PostgreSQL — with a powerful twist: every workflow maintains permanent, state that persists independently of the workflow itself.
8
+
9
+ This means:
10
+
11
+ * Any number of lightweight, thread-safe **hook workers** can attach to the same workflow record at any time.
12
+ * These hooks can safely **read and write** to shared state.
13
+ * The result is a **durable execution model** with **evolving memory**, ideal for **human-in-the-loop processes** and **AI agents that learn over time**.
13
14
 
14
15
  ---
15
16
 
@@ -17,7 +18,7 @@ processes and AI agents that learn over time.
17
18
 
18
19
  1. 🚀 Quick Start
19
20
  2. 🧠 How Permanent Memory Works
20
- 3. 🔌 Hooks & Context API
21
+ 3. 🔌 Hooks & Entity API
21
22
  4. 🤖 Building Durable AI Agents
22
23
  5. 🔬 Advanced Patterns & Recipes
23
24
  6. 📚 Documentation & Links
@@ -50,9 +51,11 @@ async function main() {
50
51
 
51
52
  // Kick off a workflow
52
53
  const handle = await mf.workflow.start({
53
- workflowName: 'example',
54
+ entity: 'user',
55
+ workflowName: 'userExample',
56
+ workflowId: 'jane@hotmesh.com',
54
57
  args: ['Jane'],
55
- taskQueue: 'contextual'
58
+ taskQueue: 'entityqueue'
56
59
  });
57
60
 
58
61
  console.log('Result:', await handle.result());
@@ -61,20 +64,20 @@ async function main() {
61
64
  main().catch(console.error);
62
65
  ```
63
66
 
67
+ ---
64
68
 
65
69
  ## 🧠 How Permanent Memory Works
66
70
 
67
- * **Context = JSONB row** in `<yourappname>.jobs` table
71
+ * **Entity = persistent JSON record** – each workflow's memory is stored as a JSONB row in your Postgres database
68
72
  * **Atomic operations** (`set`, `merge`, `append`, `increment`, `toggle`, `delete`, …)
69
73
  * **Transactional** – every update participates in the workflow/DB transaction
70
74
  * **Time-travel-safe** – full replay compatibility; side-effect detector guarantees determinism
71
75
  * **Hook-friendly** – any worker with the record ID can attach and mutate its slice of the JSON
72
-
73
- * Context data is stored as JSONB; add partial indexes for improved query analysis.
76
+ * **Index-friendly** - entity data is stored as JSONB; add partial indexes for improved query analysis.
74
77
 
75
78
  **Example: Adding a Partial Index for Specific Entity Types**
76
79
  ```sql
77
- -- Create a partial index for 'user' entities with specific context values
80
+ -- Create a partial index for 'user' entities with specific entity values
78
81
  CREATE INDEX idx_user_premium ON your_app.jobs (id)
79
82
  WHERE entity = 'user' AND (context->>'isPremium')::boolean = true;
80
83
  ```
@@ -82,42 +85,44 @@ This index will only be used for queries that match both conditions, making look
82
85
 
83
86
  ---
84
87
 
85
- ## 🔌 Hooks & Context API – Full Example
88
+ ## 🔌 Hooks & Entity API – Full Example
89
+
90
+ HotMesh hooks are powerful because they can be called both internally (from within a workflow) and externally (from outside, even after the workflow completes). This means you can:
91
+
92
+ * Start a workflow that sets up initial state
93
+ * Have the workflow call some hooks internally
94
+ * Let the workflow complete
95
+ * Continue to update the workflow's entity state from the outside via hooks
96
+ * Build long-running processes that evolve over time
97
+
98
+ Here's a complete example showing both internal and external hook usage:
86
99
 
87
100
  ```typescript
88
101
  import { MemFlow } from '@hotmeshio/hotmesh';
89
102
 
90
103
  /* ------------ Main workflow ------------ */
91
- export async function example(name: string): Promise<any> {
92
- //the context method provides transactional, replayable access to shared job state
93
- const ctx = await MemFlow.workflow.context();
104
+ export async function userExample(name: string): Promise<any> {
105
+ //the entity method provides transactional, replayable access to shared job state
106
+ const entity = await MemFlow.workflow.entity();
94
107
 
95
- //create the initial context (even arrays are supported)
96
- await ctx.set({
108
+ //create the initial entity (even arrays are supported)
109
+ await entity.set({
97
110
  user: { name },
98
111
  hooks: {},
99
112
  metrics: { count: 0 }
100
113
  });
101
114
 
102
- // Call two hooks in parallel to updaet the same shared context
103
- const [r1, r2] = await Promise.all([
104
- MemFlow.workflow.execHook({
105
- taskQueue: 'contextual',
106
- workflowName: 'hook1',
107
- args: [name, 'hook1'],
108
- signalId: 'hook1-complete',
109
- }),
110
- MemFlow.workflow.execHook({
111
- taskQueue: 'contextual',
112
- workflowName: 'hook2',
113
- args: [name, 'hook2'],
114
- signalId: 'hook2-complete',
115
- })
116
- ]);
117
-
118
- // merge here (or have the hooks merge in...everyone can access context)
119
- await ctx.merge({ hooks: { r1, r2 } });
120
- await ctx.increment('metrics.count', 2);
115
+ // Call one hook internally
116
+ const result1 = await MemFlow.workflow.execHook({
117
+ taskQueue: 'entityqueue',
118
+ workflowName: 'hook1',
119
+ args: [name, 'hook1'],
120
+ signalId: 'hook1-complete'
121
+ });
122
+
123
+ // merge the result
124
+ await entity.merge({ hooks: { r1: result1 } });
125
+ await entity.increment('metrics.count', 1);
121
126
 
122
127
  return "The main has completed; the db record persists and can be hydrated; hook in from the outside!";
123
128
  }
@@ -129,20 +134,78 @@ export async function hook1(name: string, kind: string): Promise<any> {
129
134
  await MemFlow.workflow.signal('hook1-complete', res);
130
135
  }
131
136
 
132
- /* ------------ Hook 2 (hooks can access shared job context) ------------ */
137
+ /* ------------ Hook 2 (hooks can access shared job entity) ------------ */
133
138
  export async function hook2(name: string, kind: string): Promise<void> {
134
- const ctx = await MemFlow.workflow.context();
135
- await ctx.merge({ user: { lastSeen: new Date().toISOString() } });
139
+ const entity = await MemFlow.workflow.entity();
140
+ await entity.merge({ user: { lastSeen: new Date().toISOString() } });
136
141
  await MemFlow.workflow.signal('hook2-complete', { ok: true });
137
142
  }
143
+
144
+ /* ------------ Worker/Hook Registration ------------ */
145
+ async function startWorker() {
146
+ const mf = await MemFlow.init({
147
+ appId: 'my-app',
148
+ engine: {
149
+ connection: {
150
+ class: Postgres,
151
+ options: { connectionString: process.env.DATABASE_URL }
152
+ }
153
+ }
154
+ });
155
+
156
+ const worker = await mf.worker.create({
157
+ taskQueue: 'entityqueue',
158
+ workflow: example
159
+ });
160
+
161
+ await mf.worker.create({
162
+ taskQueue: 'entityqueue',
163
+ workflow: hook1
164
+ });
165
+
166
+ await mf.worker.create({
167
+ taskQueue: 'entityqueue',
168
+ workflow: hook2
169
+ });
170
+
171
+ console.log('Workers and hooks started and listening...');
172
+ }
138
173
  ```
139
174
 
140
- **Highlights**
175
+ ### The Power of External Hooks
176
+
177
+ One of HotMesh's most powerful features is that workflow entities remain accessible even after the main workflow completes. By providing the original workflow ID, any authorized client can:
141
178
 
142
- * Hook functions are replay-safe.
143
- * Hook functions can safely read and write to the the *same* JSON context.
144
- * All context operations (`set`, `merge`, `append`, etc.) execute transactionally.
145
- * Context data is stored as JSONB; add partial indexes for improved query analysis.
179
+ * Hook into existing workflow entities
180
+ * Update state and trigger new processing
181
+ * Build evolving, long-running processes
182
+ * Enable human-in-the-loop workflows
183
+ * Create AI agents that learn over time
184
+
185
+ Here's how to hook into an existing workflow from the outside:
186
+
187
+ ```typescript
188
+ /* ------------ External Hook Example ------------ */
189
+ async function externalHookExample() {
190
+ const client = new MemFlow.Client({
191
+ appId: 'my-app',
192
+ engine: {
193
+ connection: {
194
+ class: Postgres,
195
+ options: { connectionString: process.env.DATABASE_URL }
196
+ }
197
+ }
198
+ });
199
+
200
+ // Start hook2 externally by providing the original workflow ID
201
+ await client.workflow.hook({
202
+ workflowId: 'jane@hotmesh.com', //id of the target workflow
203
+ taskQueue: 'entityqueue',
204
+ workflowName: 'hook2',
205
+ args: [name, 'external-hook']
206
+ });
207
+ }
208
+ ```
146
209
 
147
210
  ---
148
211
 
@@ -150,10 +213,10 @@ export async function hook2(name: string, kind: string): Promise<void> {
150
213
 
151
214
  Permanent memory unlocks a straightforward pattern for agentic systems:
152
215
 
153
- 1. **Planner workflow** – sketches a task list, seeds context.
154
- 2. **Tool hooks** – execute individual tasks, feeding intermediate results back into context.
155
- 3. **Reflector hook** – periodically summarises context into long-term memory embeddings.
156
- 4. **Supervisor workflow** – monitors metrics stored in context and decides when to finish.
216
+ 1. **Planner workflow** – sketches a task list, seeds entity state.
217
+ 2. **Tool hooks** – execute individual tasks, feeding intermediate results back into state.
218
+ 3. **Reflector hook** – periodically summarizes state into long-term memory embeddings.
219
+ 4. **Supervisor workflow** – monitors metrics stored in state and decides when to finish.
157
220
 
158
221
  Because every step is durable *and* shares the same knowledge object, agents can pause,
159
222
  restart, scale horizontally, and keep evolving their world-model indefinitely.
package/build/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { MemFlow } from './services/memflow';
5
5
  import { ClientService as Client } from './services/memflow/client';
6
6
  import { ConnectionService as Connection } from './services/memflow/connection';
7
7
  import { Search } from './services/memflow/search';
8
+ import { Entity } from './services/memflow/entity';
8
9
  import { WorkerService as Worker } from './services/memflow/worker';
9
10
  import { WorkflowService as workflow } from './services/memflow/workflow';
10
11
  import { WorkflowHandleService as WorkflowHandle } from './services/memflow/handle';
@@ -21,5 +22,5 @@ import { RedisConnection as ConnectorIORedis } from './services/connector/provid
21
22
  import { RedisConnection as ConnectorRedis } from './services/connector/providers/redis';
22
23
  import { NatsConnection as ConnectorNATS } from './services/connector/providers/nats';
23
24
  export { Connector, //factory
24
- ConnectorIORedis, ConnectorNATS, ConnectorPostgres, ConnectorRedis, HotMesh, HotMeshConfig, MeshCall, MeshData, MemFlow, MeshOS, Client, Connection, proxyActivities, Search, Worker, workflow, WorkflowHandle, Enums, Errors, Utils, KeyStore, };
25
+ ConnectorIORedis, ConnectorNATS, ConnectorPostgres, ConnectorRedis, HotMesh, HotMeshConfig, MeshCall, MeshData, MemFlow, MeshOS, Client, Connection, proxyActivities, Search, Entity, Worker, workflow, WorkflowHandle, Enums, Errors, Utils, KeyStore, };
25
26
  export * as Types from './types';
package/build/index.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Types = exports.KeyStore = exports.Utils = exports.Errors = exports.Enums = exports.WorkflowHandle = exports.workflow = exports.Worker = exports.Search = exports.proxyActivities = exports.Connection = exports.Client = exports.MeshOS = exports.MemFlow = exports.MeshData = exports.MeshCall = exports.HotMesh = exports.ConnectorRedis = exports.ConnectorPostgres = exports.ConnectorNATS = exports.ConnectorIORedis = exports.Connector = void 0;
26
+ exports.Types = exports.KeyStore = exports.Utils = exports.Errors = exports.Enums = exports.WorkflowHandle = exports.workflow = exports.Worker = exports.Entity = exports.Search = exports.proxyActivities = exports.Connection = exports.Client = exports.MeshOS = exports.MemFlow = exports.MeshData = exports.MeshCall = exports.HotMesh = exports.ConnectorRedis = exports.ConnectorPostgres = exports.ConnectorNATS = exports.ConnectorIORedis = exports.Connector = void 0;
27
27
  const hotmesh_1 = require("./services/hotmesh");
28
28
  Object.defineProperty(exports, "HotMesh", { enumerable: true, get: function () { return hotmesh_1.HotMesh; } });
29
29
  const meshcall_1 = require("./services/meshcall");
@@ -36,6 +36,8 @@ const connection_1 = require("./services/memflow/connection");
36
36
  Object.defineProperty(exports, "Connection", { enumerable: true, get: function () { return connection_1.ConnectionService; } });
37
37
  const search_1 = require("./services/memflow/search");
38
38
  Object.defineProperty(exports, "Search", { enumerable: true, get: function () { return search_1.Search; } });
39
+ const entity_1 = require("./services/memflow/entity");
40
+ Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return entity_1.Entity; } });
39
41
  const worker_1 = require("./services/memflow/worker");
40
42
  Object.defineProperty(exports, "Worker", { enumerable: true, get: function () { return worker_1.WorkerService; } });
41
43
  const workflow_1 = require("./services/memflow/workflow");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Permanent-Memory Workflows & AI Agents",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -33,7 +33,8 @@
33
33
  "test:memflow:collision": "NODE_ENV=test jest ./tests/memflow/collision/*.test.ts --detectOpenHandles --forceExit --verbose",
34
34
  "test:memflow:fatal": "NODE_ENV=test jest ./tests/memflow/fatal/*.test.ts --detectOpenHandles --forceExit --verbose",
35
35
  "test:memflow:goodbye": "NODE_ENV=test jest ./tests/memflow/goodbye/*.test.ts --detectOpenHandles --forceExit --verbose",
36
- "test:memflow:context": "NODE_ENV=test jest ./tests/memflow/context/postgres.test.ts --detectOpenHandles --forceExit --verbose",
36
+ "test:memflow:entity": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/memflow/entity/postgres.test.ts --detectOpenHandles --forceExit --verbose",
37
+ "test:memflow:agent": "NODE_ENV=test HMSH_LOGLEVEL=debug jest ./tests/memflow/agent/postgres.test.ts --detectOpenHandles --forceExit --verbose",
37
38
  "test:memflow:hello": "HMSH_TELEMETRY=debug HMSH_LOGLEVEL=debug HMSH_IS_CLUSTER=true NODE_ENV=test jest ./tests/memflow/helloworld/*.test.ts --detectOpenHandles --forceExit --verbose",
38
39
  "test:memflow:hook": "NODE_ENV=test jest ./tests/memflow/hook/*.test.ts --detectOpenHandles --forceExit --verbose",
39
40
  "test:memflow:interrupt": "NODE_ENV=test jest ./tests/memflow/interrupt/*.test.ts --detectOpenHandles --forceExit --verbose",
@@ -31,7 +31,7 @@ declare class Trigger extends Activity {
31
31
  getJobStatus(): number;
32
32
  resolveJobId(context: Partial<JobState>): string;
33
33
  resolveJobKey(context: Partial<JobState>): string;
34
- setStateNX(status?: number): Promise<void>;
34
+ setStateNX(status?: number, entity?: string): Promise<void>;
35
35
  setStats(transaction?: ProviderTransaction): Promise<void>;
36
36
  }
37
37
  export { Trigger };
@@ -27,7 +27,7 @@ class Trigger extends activity_1.Activity {
27
27
  this.mapJobData();
28
28
  this.adjacencyList = await this.filterAdjacent();
29
29
  const initialStatus = this.initStatus(options, this.adjacencyList.length);
30
- await this.setStateNX(initialStatus);
30
+ await this.setStateNX(initialStatus, options?.entity);
31
31
  await this.setStatus(initialStatus);
32
32
  this.bindSearchData(options);
33
33
  this.bindMarkerData(options);
@@ -228,9 +228,9 @@ class Trigger extends activity_1.Activity {
228
228
  const jobKey = this.config.stats?.key;
229
229
  return jobKey ? pipe_1.Pipe.resolve(jobKey, context) : '';
230
230
  }
231
- async setStateNX(status) {
231
+ async setStateNX(status, entity) {
232
232
  const jobId = this.context.metadata.jid;
233
- if (!await this.store.setStateNX(jobId, this.engine.appId, status)) {
233
+ if (!await this.store.setStateNX(jobId, this.engine.appId, status, entity)) {
234
234
  throw new errors_1.DuplicateJobError(jobId);
235
235
  }
236
236
  }
@@ -125,7 +125,7 @@ class ClientService {
125
125
  */
126
126
  start: async (options) => {
127
127
  const taskQueueName = options.taskQueue ?? options.entity;
128
- const workflowName = options.entity ?? options.workflowName;
128
+ const workflowName = options.taskQueue ? options.workflowName : (options.entity ?? options.workflowName);
129
129
  const trc = options.workflowTrace;
130
130
  const spn = options.workflowSpan;
131
131
  //hotmesh `topic` is equivalent to `queue+workflowname` pattern in other systems
@@ -151,6 +151,7 @@ class ClientService {
151
151
  search: options?.search?.data,
152
152
  marker: options?.marker,
153
153
  pending: options?.pending,
154
+ entity: options?.entity,
154
155
  });
155
156
  return new handle_1.WorkflowHandleService(hotMeshClient, workflowTopic, jobId);
156
157
  },
@@ -1,26 +1,26 @@
1
1
  import { HotMesh } from '../hotmesh';
2
2
  import { SearchService } from '../search';
3
3
  /**
4
- * The Context module provides methods for reading and writing
5
- * JSONB data to a workflow's context. The instance methods
4
+ * The Entity module provides methods for reading and writing
5
+ * JSONB data to a workflow's entity. The instance methods
6
6
  * exposed by this class are available for use from within
7
7
  * a running workflow.
8
8
  *
9
9
  * @example
10
10
  * ```typescript
11
- * //contextWorkflow.ts
11
+ * //entityWorkflow.ts
12
12
  * import { workflow } from '@hotmeshio/hotmesh';
13
13
  *
14
- * export async function contextExample(): Promise<void> {
15
- * const context = await workflow.context();
16
- * await context.set({ user: { id: 123 } });
17
- * await context.merge({ user: { name: "John" } });
18
- * const user = await context.get("user");
14
+ * export async function entityExample(): Promise<void> {
15
+ * const entity = await workflow.entity();
16
+ * await entity.set({ user: { id: 123 } });
17
+ * await entity.merge({ user: { name: "John" } });
18
+ * const user = await entity.get("user");
19
19
  * // user = { id: 123, name: "John" }
20
20
  * }
21
21
  * ```
22
22
  */
23
- export declare class Context {
23
+ export declare class Entity {
24
24
  /**
25
25
  * @private
26
26
  */
@@ -56,84 +56,84 @@ export declare class Context {
56
56
  */
57
57
  getSearchSessionGuid(): string;
58
58
  /**
59
- * Sets the entire context object. This replaces any existing context.
59
+ * Sets the entire entity object. This replaces any existing entity.
60
60
  *
61
61
  * @example
62
- * const context = await workflow.context();
63
- * await context.set({ user: { id: 123, name: "John" } });
62
+ * const entity = await workflow.entity();
63
+ * await entity.set({ user: { id: 123, name: "John" } });
64
64
  */
65
65
  set(value: any): Promise<any>;
66
66
  /**
67
- * Deep merges the provided object with the existing context
67
+ * Deep merges the provided object with the existing entity
68
68
  *
69
69
  * @example
70
- * const context = await workflow.context();
71
- * await context.merge({ user: { email: "john@example.com" } });
70
+ * const entity = await workflow.entity();
71
+ * await entity.merge({ user: { email: "john@example.com" } });
72
72
  */
73
73
  merge<T>(value: T): Promise<T>;
74
74
  /**
75
- * Gets a value from the context by path
75
+ * Gets a value from the entity by path
76
76
  *
77
77
  * @example
78
- * const context = await workflow.context();
79
- * const user = await context.get("user");
80
- * const email = await context.get("user.email");
78
+ * const entity = await workflow.entity();
79
+ * const user = await entity.get("user");
80
+ * const email = await entity.get("user.email");
81
81
  */
82
82
  get(path?: string): Promise<any>;
83
83
  /**
84
- * Deletes a value from the context by path
84
+ * Deletes a value from the entity by path
85
85
  *
86
86
  * @example
87
- * const context = await workflow.context();
88
- * await context.delete("user.email");
87
+ * const entity = await workflow.entity();
88
+ * await entity.delete("user.email");
89
89
  */
90
90
  delete(path: string): Promise<any>;
91
91
  /**
92
92
  * Appends a value to an array at the specified path
93
93
  *
94
94
  * @example
95
- * const context = await workflow.context();
96
- * await context.append("items", { id: 1, name: "New Item" });
95
+ * const entity = await workflow.entity();
96
+ * await entity.append("items", { id: 1, name: "New Item" });
97
97
  */
98
98
  append(path: string, value: any): Promise<any[]>;
99
99
  /**
100
100
  * Prepends a value to an array at the specified path
101
101
  *
102
102
  * @example
103
- * const context = await workflow.context();
104
- * await context.prepend("items", { id: 0, name: "First Item" });
103
+ * const entity = await workflow.entity();
104
+ * await entity.prepend("items", { id: 0, name: "First Item" });
105
105
  */
106
106
  prepend(path: string, value: any): Promise<any[]>;
107
107
  /**
108
108
  * Removes an item from an array at the specified path and index
109
109
  *
110
110
  * @example
111
- * const context = await workflow.context();
112
- * await context.remove("items", 0); // Remove first item
111
+ * const entity = await workflow.entity();
112
+ * await entity.remove("items", 0); // Remove first item
113
113
  */
114
114
  remove(path: string, index: number): Promise<any[]>;
115
115
  /**
116
116
  * Increments a numeric value at the specified path
117
117
  *
118
118
  * @example
119
- * const context = await workflow.context();
120
- * await context.increment("counter", 5);
119
+ * const entity = await workflow.entity();
120
+ * await entity.increment("counter", 5);
121
121
  */
122
122
  increment(path: string, value?: number): Promise<number>;
123
123
  /**
124
124
  * Toggles a boolean value at the specified path
125
125
  *
126
126
  * @example
127
- * const context = await workflow.context();
128
- * await context.toggle("settings.enabled");
127
+ * const entity = await workflow.entity();
128
+ * await entity.toggle("settings.enabled");
129
129
  */
130
130
  toggle(path: string): Promise<boolean>;
131
131
  /**
132
132
  * Sets a value at the specified path only if it doesn't already exist
133
133
  *
134
134
  * @example
135
- * const context = await workflow.context();
136
- * await context.setIfNotExists("user.id", 123);
135
+ * const entity = await workflow.entity();
136
+ * await entity.setIfNotExists("user.id", 123);
137
137
  */
138
138
  setIfNotExists(path: string, value: any): Promise<any>;
139
139
  /**