@memberjunction/aiengine 2.51.0 → 2.52.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 +40 -0
- package/dist/agent-types.d.ts +4 -3
- package/dist/agent-types.d.ts.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -220,6 +220,46 @@ import { LoopAgentType } from '@memberjunction/aiengine';
|
|
|
220
220
|
// - Execution flow control
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
+
### Type-Safe Sub-Agent Requests (New in v2.51.0)
|
|
224
|
+
|
|
225
|
+
The AI Engine now provides type-safe context propagation for sub-agent requests. Context is optional in the request definition and is provided at execution time by the framework:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { AgentSubAgentRequest, BaseAgentNextStep } from '@memberjunction/aiengine';
|
|
229
|
+
|
|
230
|
+
// Define your context type
|
|
231
|
+
interface MyContext {
|
|
232
|
+
apiEndpoint: string;
|
|
233
|
+
apiKey: string;
|
|
234
|
+
environment: 'dev' | 'staging' | 'prod';
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Create a typed sub-agent request - context is optional here
|
|
238
|
+
const subAgentRequest: AgentSubAgentRequest<MyContext> = {
|
|
239
|
+
id: 'sub-agent-uuid',
|
|
240
|
+
name: 'DataProcessorAgent',
|
|
241
|
+
message: 'Process the uploaded data',
|
|
242
|
+
terminateAfter: false
|
|
243
|
+
// context is NOT set by AI agents - it's provided by the framework at execution time
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Use in agent next step decisions
|
|
247
|
+
const nextStep: BaseAgentNextStep<MyContext> = {
|
|
248
|
+
step: 'sub-agent',
|
|
249
|
+
subAgent: subAgentRequest
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// At execution time, the framework provides the context:
|
|
253
|
+
// The parent agent's context is automatically passed to sub-agents
|
|
254
|
+
// This ensures consistent runtime configuration across the agent hierarchy
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
This pattern ensures:
|
|
258
|
+
- Type safety when defining sub-agent requests
|
|
259
|
+
- Context is consistently provided by the execution framework
|
|
260
|
+
- AI agents focus on decision logic without managing runtime configuration
|
|
261
|
+
- Runtime contexts (API keys, endpoints, etc.) flow through the agent hierarchy automatically
|
|
262
|
+
|
|
223
263
|
|
|
224
264
|
## Advanced Features
|
|
225
265
|
|
package/dist/agent-types.d.ts
CHANGED
|
@@ -6,19 +6,20 @@ export type AgentAction = {
|
|
|
6
6
|
name: string;
|
|
7
7
|
params: Record<string, unknown>;
|
|
8
8
|
};
|
|
9
|
-
export type AgentSubAgentRequest = {
|
|
9
|
+
export type AgentSubAgentRequest<TContext = any> = {
|
|
10
10
|
id: string;
|
|
11
11
|
name: string;
|
|
12
12
|
message: string;
|
|
13
13
|
terminateAfter: boolean;
|
|
14
|
+
context?: TContext;
|
|
14
15
|
};
|
|
15
|
-
export type BaseAgentNextStep = {
|
|
16
|
+
export type BaseAgentNextStep<TContext = any> = {
|
|
16
17
|
step: 'success' | 'failed' | 'retry' | 'sub-agent' | 'actions' | 'chat';
|
|
17
18
|
returnValue?: any;
|
|
18
19
|
errorMessage?: string;
|
|
19
20
|
retryReason?: string;
|
|
20
21
|
retryInstructions?: string;
|
|
21
|
-
subAgent?: AgentSubAgentRequest
|
|
22
|
+
subAgent?: AgentSubAgentRequest<TContext>;
|
|
22
23
|
actions?: AgentAction[];
|
|
23
24
|
userMessage?: string;
|
|
24
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-types.d.ts","sourceRoot":"","sources":["../src/agent-types.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAUhF,MAAM,MAAM,W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AE,CAAA;KAAE,CAAC;CACjD,CAAA;AAaD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;CACrC,CAAA;AAQD,MAAM,MAAM,eAAe,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,oBAAoB,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/aiengine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.52.0",
|
|
4
4
|
"description": "MemberJunction: AI Engine Package - handles automatic execution of Entity AI Actions using AI Models",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"author": "MemberJunction.com",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/core": "2.
|
|
19
|
-
"@memberjunction/global": "2.
|
|
20
|
-
"@memberjunction/core-entities": "2.
|
|
21
|
-
"@memberjunction/ai": "2.
|
|
22
|
-
"@memberjunction/ai-engine-base": "2.
|
|
18
|
+
"@memberjunction/core": "2.52.0",
|
|
19
|
+
"@memberjunction/global": "2.52.0",
|
|
20
|
+
"@memberjunction/core-entities": "2.52.0",
|
|
21
|
+
"@memberjunction/ai": "2.52.0",
|
|
22
|
+
"@memberjunction/ai-engine-base": "2.52.0",
|
|
23
23
|
"dotenv": "^16.4.1",
|
|
24
24
|
"rxjs": "^7.8.1"
|
|
25
25
|
},
|