@memberjunction/ai-agents 2.50.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 +774 -3
- package/dist/AgentRunner.d.ts +2 -1
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +5 -2
- package/dist/AgentRunner.js.map +1 -1
- package/dist/agent-types/base-agent-type.d.ts +6 -0
- package/dist/agent-types/base-agent-type.d.ts.map +1 -0
- package/dist/agent-types/base-agent-type.js.map +1 -0
- package/dist/agent-types/index.d.ts +2 -1
- package/dist/agent-types/index.d.ts.map +1 -1
- package/dist/agent-types/index.js +4 -3
- package/dist/agent-types/index.js.map +1 -1
- package/dist/agent-types/{LoopAgentType.d.ts → loop-agent-type.d.ts} +4 -4
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -0
- package/dist/agent-types/{LoopAgentType.js → loop-agent-type.js} +71 -42
- package/dist/agent-types/loop-agent-type.js.map +1 -0
- package/dist/base-agent.d.ts +49 -1
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +1097 -98
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +35 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/agent-types/LoopAgentType.d.ts.map +0 -1
- package/dist/agent-types/LoopAgentType.js.map +0 -1
- package/dist/base-agent-type.d.ts +0 -6
- package/dist/base-agent-type.d.ts.map +0 -1
- package/dist/base-agent-type.js.map +0 -1
- /package/dist/{base-agent-type.js → agent-types/base-agent-type.js} +0 -0
package/dist/AgentRunner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExecuteAgentResult } from '@memberjunction/aiengine';
|
|
2
|
+
import { ExecuteAgentParams } from './types';
|
|
2
3
|
export declare class AgentRunner {
|
|
3
4
|
RunAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResult>;
|
|
4
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentRunner.d.ts","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AgentRunner.d.ts","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAqB7C,qBAAa,WAAW;IAcP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4CjF"}
|
package/dist/AgentRunner.js
CHANGED
|
@@ -26,8 +26,11 @@ class AgentRunner {
|
|
|
26
26
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
27
27
|
(0, core_1.LogError)(`AgentRunner execution failed: ${errorMessage}`, undefined, error);
|
|
28
28
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
success: false,
|
|
30
|
+
finalStep: 'failed',
|
|
31
|
+
errorMessage,
|
|
32
|
+
agentRun: null,
|
|
33
|
+
executionTree: []
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
}
|
package/dist/AgentRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentRunner.js","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":";;;AAYA,+CAA2D;AAC3D,mDAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"AgentRunner.js","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":";;;AAYA,+CAA2D;AAC3D,mDAAkD;AAClD,uDAAwE;AACxE,6CAAyC;AAsBzC,MAAa,WAAW;IAcb,KAAK,CAAC,QAAQ,CAAC,MAA0B;QAC5C,IAAI,CAAC;YACD,IAA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YAAY;gBACZ,QAAQ,EAAE,IAAW;gBACrB,aAAa,EAAE,EAAE;aACpB,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AA1DD,kCA0DC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AIPromptRunResult } from '@memberjunction/ai';
|
|
2
|
+
import { BaseAgentNextStep } from '@memberjunction/aiengine';
|
|
3
|
+
export declare abstract class BaseAgentType {
|
|
4
|
+
abstract DetermineNextStep(promptResult: AIPromptRunResult): Promise<BaseAgentNextStep>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=base-agent-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAoC7D,8BAAsB,aAAa;aA4Bf,iBAAiB,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CACjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":";;;AAkDA,MAAsB,aAAa;CA6BlC;AA7BD,sCA6BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":"AAYA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":"AAYA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
__exportStar(require("./base-agent-type"), exports);
|
|
18
|
+
__exportStar(require("./loop-agent-type"), exports);
|
|
19
|
+
const loop_agent_type_1 = require("./loop-agent-type");
|
|
20
|
+
(0, loop_agent_type_1.LoadLoopAgentType)();
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,oDAAkC;AAClC,oDAAkC;AAGlC,uDAAsD;AACtD,IAAA,mCAAiB,GAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseAgentType } from '
|
|
2
|
-
import { BaseAgentNextStep } from '
|
|
3
|
-
import { AIPromptRunResult } from '@memberjunction/ai
|
|
1
|
+
import { BaseAgentType } from './base-agent-type';
|
|
2
|
+
import { BaseAgentNextStep } from '@memberjunction/aiengine';
|
|
3
|
+
import { AIPromptRunResult } from '@memberjunction/ai';
|
|
4
4
|
export declare class LoopAgentType extends BaseAgentType {
|
|
5
5
|
DetermineNextStep(promptResult: AIPromptRunResult): Promise<BaseAgentNextStep>;
|
|
6
6
|
private isValidLoopResponse;
|
|
7
7
|
}
|
|
8
8
|
export declare function LoadLoopAgentType(): void;
|
|
9
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=loop-agent-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-type.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAsJvD,qBACa,aAAc,SAAQ,aAAa;IAa/B,iBAAiB,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiI3F,OAAO,CAAC,mBAAmB;CAiD9B;AAKD,wBAAgB,iBAAiB,SAEhC"}
|
|
@@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.LoadLoopAgentType = exports.LoopAgentType = void 0;
|
|
10
10
|
const global_1 = require("@memberjunction/global");
|
|
11
|
-
const base_agent_type_1 = require("
|
|
11
|
+
const base_agent_type_1 = require("./base-agent-type");
|
|
12
12
|
const core_1 = require("@memberjunction/core");
|
|
13
13
|
let LoopAgentType = class LoopAgentType extends base_agent_type_1.BaseAgentType {
|
|
14
14
|
async DetermineNextStep(promptResult) {
|
|
@@ -19,66 +19,86 @@ let LoopAgentType = class LoopAgentType extends base_agent_type_1.BaseAgentType
|
|
|
19
19
|
errorMessage: promptResult.errorMessage || 'Prompt execution failed'
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
let response;
|
|
23
|
+
try {
|
|
24
|
+
if (typeof promptResult.result === 'string') {
|
|
25
|
+
response = JSON.parse(promptResult.result);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
response = promptResult.result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (parseError) {
|
|
24
32
|
return {
|
|
25
33
|
step: 'failed',
|
|
26
|
-
errorMessage:
|
|
34
|
+
errorMessage: `Failed to parse JSON response: ${parseError.message}`
|
|
27
35
|
};
|
|
28
36
|
}
|
|
29
|
-
(
|
|
30
|
-
if (response.progress) {
|
|
31
|
-
(0, core_1.LogStatus)(`📊 Progress: ${response.progress.percentage}% - ${response.progress.message}`);
|
|
32
|
-
}
|
|
33
|
-
if (response.error?.occurred) {
|
|
37
|
+
if (!this.isValidLoopResponse(response)) {
|
|
34
38
|
return {
|
|
35
39
|
step: 'failed',
|
|
36
|
-
errorMessage: response
|
|
40
|
+
errorMessage: 'Invalid response structure from loop agent prompt'
|
|
37
41
|
};
|
|
38
42
|
}
|
|
43
|
+
(0, core_1.LogStatus)(`🔄 Loop Agent Reasoning: ${response.reasoning}`);
|
|
44
|
+
if (response.confidence !== undefined) {
|
|
45
|
+
(0, core_1.LogStatus)(`🎯 Confidence: ${(response.confidence * 100).toFixed(0)}%`);
|
|
46
|
+
}
|
|
39
47
|
if (response.taskComplete) {
|
|
40
48
|
(0, core_1.LogStatus)('✅ Loop Agent: Task completed successfully');
|
|
41
49
|
return {
|
|
42
50
|
step: 'success',
|
|
43
|
-
returnValue: response
|
|
51
|
+
returnValue: response
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (!response.nextStep) {
|
|
55
|
+
return {
|
|
56
|
+
step: 'failed',
|
|
57
|
+
errorMessage: 'Task not complete but no next step provided'
|
|
44
58
|
};
|
|
45
59
|
}
|
|
46
60
|
switch (response.nextStep.type) {
|
|
47
61
|
case 'sub-agent':
|
|
48
|
-
if (!response.nextStep.
|
|
62
|
+
if (!response.nextStep.subAgent) {
|
|
49
63
|
return {
|
|
50
64
|
step: 'failed',
|
|
51
|
-
errorMessage: 'Sub-agent
|
|
65
|
+
errorMessage: 'Sub-agent details not specified'
|
|
52
66
|
};
|
|
53
67
|
}
|
|
54
68
|
return {
|
|
55
69
|
step: 'sub-agent',
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
subAgent: {
|
|
71
|
+
id: response.nextStep.subAgent.id,
|
|
72
|
+
name: response.nextStep.subAgent.name,
|
|
73
|
+
message: response.nextStep.subAgent.message,
|
|
74
|
+
terminateAfter: response.nextStep.subAgent.terminateAfter
|
|
75
|
+
}
|
|
58
76
|
};
|
|
59
77
|
case 'action':
|
|
60
|
-
if (!response.nextStep.
|
|
78
|
+
if (!response.nextStep.actions || response.nextStep.actions.length === 0) {
|
|
61
79
|
return {
|
|
62
80
|
step: 'failed',
|
|
63
|
-
errorMessage: '
|
|
81
|
+
errorMessage: 'Actions not specified'
|
|
64
82
|
};
|
|
65
83
|
}
|
|
66
84
|
return {
|
|
67
|
-
step: '
|
|
68
|
-
|
|
69
|
-
|
|
85
|
+
step: 'actions',
|
|
86
|
+
actions: response.nextStep.actions.map(action => ({
|
|
87
|
+
id: action.id,
|
|
88
|
+
name: action.name,
|
|
89
|
+
params: action.params
|
|
90
|
+
}))
|
|
70
91
|
};
|
|
71
|
-
case '
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(0, core_1.LogStatus)('⚠️ Loop Agent: No next step but task not complete');
|
|
92
|
+
case 'chat':
|
|
93
|
+
if (!response.nextStep.userMessage) {
|
|
94
|
+
return {
|
|
95
|
+
step: 'failed',
|
|
96
|
+
errorMessage: 'Chat type specified but no user message provided'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
79
99
|
return {
|
|
80
|
-
step: '
|
|
81
|
-
|
|
100
|
+
step: 'chat',
|
|
101
|
+
userMessage: response.nextStep.userMessage
|
|
82
102
|
};
|
|
83
103
|
default:
|
|
84
104
|
return {
|
|
@@ -107,19 +127,28 @@ let LoopAgentType = class LoopAgentType extends base_agent_type_1.BaseAgentType
|
|
|
107
127
|
(0, core_1.LogError)('LoopAgentResponse missing required field: reasoning');
|
|
108
128
|
return false;
|
|
109
129
|
}
|
|
110
|
-
if (!response.
|
|
111
|
-
(0, core_1.LogError)('LoopAgentResponse
|
|
130
|
+
if (!response.taskComplete && !response.nextStep) {
|
|
131
|
+
(0, core_1.LogError)('LoopAgentResponse requires nextStep when taskComplete is false');
|
|
112
132
|
return false;
|
|
113
133
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
!response.nextStep.
|
|
121
|
-
|
|
122
|
-
|
|
134
|
+
if (response.nextStep) {
|
|
135
|
+
const validStepTypes = ['action', 'sub-agent', 'chat'];
|
|
136
|
+
if (!validStepTypes.includes(response.nextStep.type)) {
|
|
137
|
+
(0, core_1.LogError)(`LoopAgentResponse has invalid nextStep.type: ${response.nextStep.type}`);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
if (response.nextStep.type === 'action' && !response.nextStep.actions) {
|
|
141
|
+
(0, core_1.LogError)('LoopAgentResponse requires actions array for action type');
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
if (response.nextStep.type === 'sub-agent' && !response.nextStep.subAgent) {
|
|
145
|
+
(0, core_1.LogError)('LoopAgentResponse requires subAgent object for sub-agent type');
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
if (response.nextStep.type === 'chat' && !response.nextStep.userMessage) {
|
|
149
|
+
(0, core_1.LogError)('LoopAgentResponse requires userMessage for chat type');
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
123
152
|
}
|
|
124
153
|
return true;
|
|
125
154
|
}
|
|
@@ -131,4 +160,4 @@ exports.LoopAgentType = LoopAgentType = __decorate([
|
|
|
131
160
|
function LoadLoopAgentType() {
|
|
132
161
|
}
|
|
133
162
|
exports.LoadLoopAgentType = LoadLoopAgentType;
|
|
134
|
-
//# sourceMappingURL=
|
|
163
|
+
//# sourceMappingURL=loop-agent-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-type.ts"],"names":[],"mappings":";;;;;;;;;AAYA,mDAAuD;AACvD,uDAAkD;AAGlD,+CAA2D;AAsJpD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,+BAA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
-
import {
|
|
1
|
+
import { AIAgentEntity, AIAgentTypeEntity } from '@memberjunction/core-entities';
|
|
2
|
+
import { UserInfo } from '@memberjunction/core';
|
|
3
|
+
import { AIPromptParams } from '@memberjunction/ai-prompts';
|
|
4
|
+
import { ChatMessage } from '@memberjunction/ai';
|
|
5
|
+
import { ExecuteAgentParams, AgentConfiguration } from './types';
|
|
6
|
+
import { ExecuteAgentResult, AgentAction, AgentSubAgentRequest, BaseAgentNextStep } from '@memberjunction/aiengine';
|
|
2
7
|
export declare class BaseAgent {
|
|
3
8
|
private _promptRunner;
|
|
9
|
+
private _metadata;
|
|
10
|
+
private _runContext;
|
|
11
|
+
private _agentRun;
|
|
12
|
+
private _executionChain;
|
|
13
|
+
private _allProgressSteps;
|
|
14
|
+
private _subAgentRuns;
|
|
15
|
+
private getAgentRunSteps;
|
|
16
|
+
private wrapProgressCallback;
|
|
4
17
|
Execute(params: ExecuteAgentParams): Promise<ExecuteAgentResult>;
|
|
18
|
+
protected initializeEngines(contextUser?: UserInfo): Promise<void>;
|
|
19
|
+
protected validateAgent(agent: AIAgentEntity): Promise<ExecuteAgentResult | null>;
|
|
20
|
+
protected loadAgentConfiguration(agent: AIAgentEntity): Promise<AgentConfiguration>;
|
|
21
|
+
protected preparePromptParams(agentType: AIAgentTypeEntity, systemPrompt: any, childPrompt: any, params: ExecuteAgentParams): Promise<AIPromptParams>;
|
|
22
|
+
protected executePrompt(promptParams: AIPromptParams): Promise<any>;
|
|
23
|
+
protected processNextStep(params: ExecuteAgentParams, agentType: AIAgentTypeEntity, promptResult: any): Promise<BaseAgentNextStep>;
|
|
24
|
+
protected createActionResultMessage(actions: AgentAction[], results: any[]): ChatMessage;
|
|
25
|
+
protected createSubAgentResultMessage(subAgent: AgentSubAgentRequest, result: any): ChatMessage;
|
|
5
26
|
private gatherContextData;
|
|
6
27
|
private getAgentTypeInstance;
|
|
7
28
|
private getAgentInstanceWithDriverClass;
|
|
29
|
+
ExecuteActions(params: ExecuteAgentParams, actions: AgentAction[], contextUser?: UserInfo): Promise<any[]>;
|
|
30
|
+
protected ExecuteSubAgent(params: ExecuteAgentParams, subAgentRequest: AgentSubAgentRequest): Promise<ExecuteAgentResult>;
|
|
31
|
+
private formatSubAgentDetails;
|
|
32
|
+
private formatActionDetails;
|
|
33
|
+
private formatActionParameter;
|
|
34
|
+
private getAgentTypeName;
|
|
35
|
+
private getValueListItems;
|
|
36
|
+
private getActionCategoryName;
|
|
37
|
+
private inferResultCodeUsage;
|
|
38
|
+
private initializeAgentRun;
|
|
39
|
+
private validateAgentWithTracking;
|
|
40
|
+
private createStepEntity;
|
|
41
|
+
private finalizeStepEntity;
|
|
42
|
+
private formatHierarchicalMessage;
|
|
43
|
+
private executeNextStep;
|
|
44
|
+
private executePromptStep;
|
|
45
|
+
private executeSubAgentStep;
|
|
46
|
+
private executeActionsStep;
|
|
47
|
+
private executeChatStep;
|
|
48
|
+
private createFailureResult;
|
|
49
|
+
private createCancelledResult;
|
|
50
|
+
private finalizeAgentRun;
|
|
51
|
+
private countStepsInTree;
|
|
52
|
+
private buildExecutionTree;
|
|
53
|
+
private sortExecutionTreeByStepNumber;
|
|
54
|
+
private getNextStepReasoning;
|
|
55
|
+
private getNextStepDetails;
|
|
8
56
|
}
|
|
9
57
|
//# sourceMappingURL=base-agent.d.ts.map
|
package/dist/base-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-agent.d.ts","sourceRoot":"","sources":["../src/base-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-agent.d.ts","sourceRoot":"","sources":["../src/base-agent.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA0C,MAAM,+BAA+B,CAAC;AACzH,OAAO,EAAE,QAAQ,EAAqB,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAkB,cAAc,EAAoB,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAqB,M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