@memberjunction/actions 1.4.1
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/dist/entity-actions/EntityActionEngine.d.ts +93 -0
- package/dist/entity-actions/EntityActionEngine.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionEngine.js +134 -0
- package/dist/entity-actions/EntityActionEngine.js.map +1 -0
- package/dist/entity-actions/EntityActionEntity.server.d.ts +20 -0
- package/dist/entity-actions/EntityActionEntity.server.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionEntity.server.js +54 -0
- package/dist/entity-actions/EntityActionEntity.server.js.map +1 -0
- package/dist/entity-actions/EntityActionInvocationTypes.d.ts +29 -0
- package/dist/entity-actions/EntityActionInvocationTypes.d.ts.map +1 -0
- package/dist/entity-actions/EntityActionInvocationTypes.js +108 -0
- package/dist/entity-actions/EntityActionInvocationTypes.js.map +1 -0
- package/dist/generic/ActionEngine.d.ts +161 -0
- package/dist/generic/ActionEngine.d.ts.map +1 -0
- package/dist/generic/ActionEngine.js +218 -0
- package/dist/generic/ActionEngine.js.map +1 -0
- package/dist/generic/ActionEntity.server.d.ts +50 -0
- package/dist/generic/ActionEntity.server.d.ts.map +1 -0
- package/dist/generic/ActionEntity.server.js +395 -0
- package/dist/generic/ActionEntity.server.js.map +1 -0
- package/dist/generic/BaseAction.d.ts +9 -0
- package/dist/generic/BaseAction.d.ts.map +1 -0
- package/dist/generic/BaseAction.js +13 -0
- package/dist/generic/BaseAction.js.map +1 -0
- package/dist/generic/BaseActionFilter.d.ts +20 -0
- package/dist/generic/BaseActionFilter.d.ts.map +1 -0
- package/dist/generic/BaseActionFilter.js +21 -0
- package/dist/generic/BaseActionFilter.js.map +1 -0
- package/dist/generic/test.d.ts +1 -0
- package/dist/generic/test.d.ts.map +1 -0
- package/dist/generic/test.js +73 -0
- package/dist/generic/test.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
- package/readme.md +6 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionEngine = exports.RunActionParams = exports.ActionParam = exports.ActionResult = exports.ActionResultSimple = exports.GeneratedCode = exports.ActionLibrary = void 0;
|
|
4
|
+
const core_1 = require("@memberjunction/core");
|
|
5
|
+
const global_1 = require("@memberjunction/global");
|
|
6
|
+
const BaseAction_1 = require("./BaseAction");
|
|
7
|
+
class ActionLibrary {
|
|
8
|
+
}
|
|
9
|
+
exports.ActionLibrary = ActionLibrary;
|
|
10
|
+
/**
|
|
11
|
+
* Class that is used for passing around generated code includes properties such as the code itself and a description of what the code does.
|
|
12
|
+
*/
|
|
13
|
+
class GeneratedCode {
|
|
14
|
+
}
|
|
15
|
+
exports.GeneratedCode = GeneratedCode;
|
|
16
|
+
/**
|
|
17
|
+
* Class that has the result of the individual action execution and used by the engine or other caller
|
|
18
|
+
*/
|
|
19
|
+
class ActionResultSimple {
|
|
20
|
+
}
|
|
21
|
+
exports.ActionResultSimple = ActionResultSimple;
|
|
22
|
+
/**
|
|
23
|
+
* Class that has the result of a complete action execution, returned by the Run method of the ActionEngine.
|
|
24
|
+
*/
|
|
25
|
+
class ActionResult {
|
|
26
|
+
}
|
|
27
|
+
exports.ActionResult = ActionResult;
|
|
28
|
+
/**
|
|
29
|
+
* Generic class for holding parameters for an action for both inputs and outputs
|
|
30
|
+
*/
|
|
31
|
+
class ActionParam {
|
|
32
|
+
}
|
|
33
|
+
exports.ActionParam = ActionParam;
|
|
34
|
+
/**
|
|
35
|
+
* Class that holds the parameters for an action to be run. This is passed to the Run method of an action.
|
|
36
|
+
*/
|
|
37
|
+
class RunActionParams {
|
|
38
|
+
}
|
|
39
|
+
exports.RunActionParams = RunActionParams;
|
|
40
|
+
/**
|
|
41
|
+
* Base class for executing actions. This class can be sub-classed if desired if you would like to modify the logic across ALL actions. To do so, sub-class this class and use the
|
|
42
|
+
* @RegisterClass decorator from the @memberjunction/global package to register your sub-class with the ClassFactory. This will cause your sub-class to be used instead of this base class when the Metadata object insantiates the ActionEngine.
|
|
43
|
+
*/
|
|
44
|
+
class ActionEngine extends core_1.BaseEngine {
|
|
45
|
+
// implement a singleton pattern for caching metadata. All uses of the ActionEngine will first call Config() to get started which is an async method. This method will load the metadata and cache it in a variable wtihin the "GlobalObjectStore"
|
|
46
|
+
// which is an MJ utility that is available to all packages. This will allow the metadata to be loaded once and then used by all instances of the ActionEngine. This is important because the metadata is not expected to change.
|
|
47
|
+
constructor() {
|
|
48
|
+
super('MJ_Action_Metadata');
|
|
49
|
+
this.__coreCategoryName = '__mj';
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the global instance of the class. This is a singleton class, so there is only one instance of it in the application. Do not directly create new instances of it, always use this method to get the instance.
|
|
53
|
+
*/
|
|
54
|
+
static get Instance() {
|
|
55
|
+
return super.getInstance('MJ_Action_Metadata');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* This method is called to configure the ActionEngine. It loads the metadata for the actions, filters, and result codes and caches them in the GlobalObjectStore. You must call this method before running any actions.
|
|
59
|
+
* If this method was previously run on the instance of the ActionEngine, it will return immediately without re-loading the metadata. If you want to force a reload of the metadata, you can pass true for the forceReload parameter.
|
|
60
|
+
* @param forceRefresh If true, the metadata will be loaded from the database even if it was previously loaded.
|
|
61
|
+
* @param contextUser If you are running the action on the server side you must pass this in, but it is not required in an environment where a user is authenticated directly, e.g. a browser or other client.
|
|
62
|
+
*/
|
|
63
|
+
async Config(forceRefresh = false, contextUser) {
|
|
64
|
+
const config = [
|
|
65
|
+
{
|
|
66
|
+
EntityName: 'Actions',
|
|
67
|
+
PropertyName: '_Actions'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
EntityName: 'Action Filters',
|
|
71
|
+
PropertyName: '_Filters'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
EntityName: 'Action Result Codes',
|
|
75
|
+
PropertyName: '_ActionResultCodes'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
EntityName: 'Action Params',
|
|
79
|
+
PropertyName: '_Params'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
EntityName: 'Action Libraries',
|
|
83
|
+
PropertyName: '_ActionLibraries'
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
await this.Load(config, forceRefresh, contextUser);
|
|
87
|
+
}
|
|
88
|
+
get Actions() {
|
|
89
|
+
return this._Actions;
|
|
90
|
+
}
|
|
91
|
+
get ActionParams() {
|
|
92
|
+
return this._Params;
|
|
93
|
+
}
|
|
94
|
+
get ActionFilters() {
|
|
95
|
+
return this._Filters;
|
|
96
|
+
}
|
|
97
|
+
get ActionResultCodes() {
|
|
98
|
+
return this._ActionResultCodes;
|
|
99
|
+
}
|
|
100
|
+
get ActionLibraries() {
|
|
101
|
+
return this._ActionLibraries;
|
|
102
|
+
}
|
|
103
|
+
get CoreActions() {
|
|
104
|
+
return this._Actions.filter((a) => a.IsCoreAction);
|
|
105
|
+
}
|
|
106
|
+
get NonCoreActions() {
|
|
107
|
+
return this._Actions.filter((a) => !a.IsCoreAction);
|
|
108
|
+
}
|
|
109
|
+
get CoreCategoryName() {
|
|
110
|
+
return this.__coreCategoryName;
|
|
111
|
+
}
|
|
112
|
+
async RunAction(params) {
|
|
113
|
+
if (await this.ValidateInputs(params)) {
|
|
114
|
+
if (await this.RunFilters(params)) {
|
|
115
|
+
return await this.InternalRunAction(params);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// filters indicated we should NOT run this action
|
|
119
|
+
const result = {
|
|
120
|
+
Success: true,
|
|
121
|
+
Message: "Filters were run and the result indicated this action should not be executed. This is a Success condition as filters returning false is not considered an error.",
|
|
122
|
+
LogEntry: null, // initially null
|
|
123
|
+
Params: [],
|
|
124
|
+
RunParams: params
|
|
125
|
+
};
|
|
126
|
+
result.LogEntry = await this.StartAndEndActionLog(params, result);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// input validation failed
|
|
131
|
+
return {
|
|
132
|
+
Success: false,
|
|
133
|
+
Message: "Input validation failed. This is a failure condition.",
|
|
134
|
+
LogEntry: null,
|
|
135
|
+
Params: [],
|
|
136
|
+
RunParams: params
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* This method handles input validation. Subclasses can override this method to provide custom input validation.
|
|
142
|
+
*/
|
|
143
|
+
async ValidateInputs(params) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* This method runs any filters for the action. Subclasses can override this method to provide custom filter logic.
|
|
148
|
+
*/
|
|
149
|
+
async RunFilters(params) {
|
|
150
|
+
if (params.Filters) {
|
|
151
|
+
for (let filter of params.Filters) {
|
|
152
|
+
if (!await this.RunSingleFilter(params, filter)) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return true; // if we get here we either had no filters or passed them all
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* This method runs a single filter. Subclasses can override this method to provide custom filter logic.
|
|
161
|
+
* @param filter
|
|
162
|
+
*/
|
|
163
|
+
async RunSingleFilter(params, filter) {
|
|
164
|
+
return true;
|
|
165
|
+
// temp stub above, replace with code that will run the filter
|
|
166
|
+
}
|
|
167
|
+
async InternalRunAction(params) {
|
|
168
|
+
// this is where the actual action code will be implemented
|
|
169
|
+
// first, let's get the right BaseAction derived sub-class for this particular action
|
|
170
|
+
// using ClassFactory
|
|
171
|
+
const logEntry = await this.StartActionLog(params);
|
|
172
|
+
const action = global_1.MJGlobal.Instance.ClassFactory.CreateInstance(BaseAction_1.BaseAction, params.Action.Name);
|
|
173
|
+
if (!action)
|
|
174
|
+
throw new Error(`Could not find a class for action ${params.Action.Name}.`);
|
|
175
|
+
// we now have the action class for this particular action, so run it
|
|
176
|
+
const simpleResult = await action.Run(params);
|
|
177
|
+
const resultCodeEntity = this.ActionResultCodes.find(r => r.ActionID === params.Action.ID &&
|
|
178
|
+
r.ResultCode.trim().toLowerCase() === simpleResult.ResultCode.trim().toLowerCase());
|
|
179
|
+
const result = {
|
|
180
|
+
RunParams: params,
|
|
181
|
+
Success: simpleResult.Success,
|
|
182
|
+
Message: simpleResult.Message,
|
|
183
|
+
LogEntry: null,
|
|
184
|
+
Params: simpleResult.Params,
|
|
185
|
+
Result: resultCodeEntity
|
|
186
|
+
};
|
|
187
|
+
await this.EndActionLog(logEntry, params, result);
|
|
188
|
+
result.LogEntry = logEntry;
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
async StartActionLog(params, saveRecord = true) {
|
|
192
|
+
// this is where the log entry for the action run will be created
|
|
193
|
+
const md = new core_1.Metadata();
|
|
194
|
+
const logEntity = await md.GetEntityObject('Action Execution Logs', this.ContextUser);
|
|
195
|
+
logEntity.NewRecord();
|
|
196
|
+
logEntity.ActionID = params.Action.ID;
|
|
197
|
+
logEntity.StartedAt = new Date();
|
|
198
|
+
logEntity.UserID = this.ContextUser.ID;
|
|
199
|
+
logEntity.Params = JSON.stringify(params.Params); // we will save this again in the EndActionLog, this is the initial state, and the action could add/modify the params
|
|
200
|
+
if (saveRecord)
|
|
201
|
+
await logEntity.Save(); // initial save so we persist that the action has started, unless the saveRecord parameter tells us not to save
|
|
202
|
+
return logEntity;
|
|
203
|
+
}
|
|
204
|
+
async EndActionLog(logEntity, params, result) {
|
|
205
|
+
// this is where the log entry for the action run will be created
|
|
206
|
+
logEntity.EndedAt = new Date();
|
|
207
|
+
logEntity.Params = JSON.stringify(params.Params);
|
|
208
|
+
logEntity.ResultCode = result.Result?.ResultCode;
|
|
209
|
+
await logEntity.Save(); // save a second time to record the action ending
|
|
210
|
+
}
|
|
211
|
+
async StartAndEndActionLog(params, result) {
|
|
212
|
+
const logEntity = await this.StartActionLog(params, false); // don't do the initial save
|
|
213
|
+
await this.EndActionLog(logEntity, params, result);
|
|
214
|
+
return logEntity;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
exports.ActionEngine = ActionEngine;
|
|
218
|
+
//# sourceMappingURL=ActionEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEngine.js","sourceRoot":"","sources":["../../src/generic/ActionEngine.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAEtE,mDAAkD;AAClD,6CAA0C;AAI1C,MAAa,aAAa;CAGzB;AAHD,sCAGC;AAED;;GAEG;AACH,MAAa,aAAa;CAqBzB;AArBD,sCAqBC;AAED;;GAEG;AAEH,MAAa,kBAAkB;CAoB9B;AApBD,gDAoBC;AAED;;GAEG;AACH,MAAa,YAAY;CA8BxB;AA9BD,oCA8BC;AAED;;GAEG;AACH,MAAa,WAAW;CASvB;AATD,kCASC;AAED;;GAEG;AACH,MAAa,eAAe;CAW3B;AAXD,0CAWC;AAGD;;;GAGG;AACH,MAAa,YAAa,SAAQ,iBAAwB;IAGvD,kPAAkP;IAClP,iOAAiO;IACjO;QACG,KAAK,CAAC,oBAAoB,CAAC,CAAC;QALvB,uBAAkB,GAAG,MAAM,CAAC;IAMpC,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,QAAQ;QACvB,OAAO,KAAK,CAAC,WAAW,CAAe,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAQD;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,eAAwB,KAAK,EAAE,WAAsB;QACtE,MAAM,MAAM,GAAG;YACZ;gBACM,UAAU,EAAE,SAAS;gBACrB,YAAY,EAAE,UAAU;aAC7B;YACD;gBACM,UAAU,EAAE,gBAAgB;gBAC5B,YAAY,EAAE,UAAU;aAC7B;YACD;gBACM,UAAU,EAAE,qBAAqB;gBACjC,YAAY,EAAE,oBAAoB;aACvC;YACD;gBACM,UAAU,EAAE,eAAe;gBAC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S,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QACvC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,qHAAqH;QACvK,IAAI,UAAU;YACX,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,+GAA+G;QAE1I,OAAO,SAAS,CAAC;IACpB,CAAC;IACS,KAAK,CAAC,YAAY,CAAC,SAAmC,EAAE,MAAuB,EAAE,MAAoB;QAC5G,iEAAiE;QACjE,SAAS,CAAC,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;QACjD,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,iDAAiD;IAC5E,CAAC;IAES,KAAK,CAAC,oBAAoB,CAAC,MAAuB,EAAE,MAAoB;QAC/E,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,4BAA4B;QACxF,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,SAAS,CAAC;IACpB,CAAC;CACH;AApMD,oCAoMC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EntityInfo, EntitySaveOptions } from "@memberjunction/core";
|
|
2
|
+
import { ActionEntity, ActionLibraryEntity, ActionParamEntity, ActionResultCodeEntity } from "@memberjunction/core-entities";
|
|
3
|
+
import { GeneratedCode } from "./ActionEngine";
|
|
4
|
+
import { BaseLLM, ChatParams } from "@memberjunction/ai";
|
|
5
|
+
/**
|
|
6
|
+
* Server-Only custom sub-class for Actions entity. This sub-class handles the process of auto-generation code for the Actions entity.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ActionEntityServerEntity extends ActionEntity {
|
|
9
|
+
constructor(Entity: EntityInfo);
|
|
10
|
+
/**
|
|
11
|
+
* Default implementation simply returns 'OpenAI' - override this in your subclass if you are using a different AI vendor.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
protected get AIVendorName(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates a programatically friendly name for the name of the Action.
|
|
17
|
+
*/
|
|
18
|
+
get ProgrammaticName(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if this action is a core MemberJunction framework action, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
get IsCoreAction(): boolean;
|
|
23
|
+
private _resultCodes;
|
|
24
|
+
/**
|
|
25
|
+
* Provides a list of possible result codes for this action.
|
|
26
|
+
*/
|
|
27
|
+
get ResultCodes(): ActionResultCodeEntity[];
|
|
28
|
+
private _params;
|
|
29
|
+
get Params(): ActionParamEntity[];
|
|
30
|
+
private _libs;
|
|
31
|
+
get Libraries(): ActionLibraryEntity[];
|
|
32
|
+
/**
|
|
33
|
+
* Override of the base Save method to handle the pre-processing to auto generate code whenever an action's UserPrompt is modified.
|
|
34
|
+
* This happens when a new record is created and also whenever the UserPrompt field is changed.
|
|
35
|
+
* @param options
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
Save(options?: EntitySaveOptions): Promise<boolean>;
|
|
39
|
+
protected SendMessage(message: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* This method will generate code using a combination of the UserPrompt field as well as the overall context of how an Action gets executed. Code from the Action is later used by CodeGen to inject into
|
|
42
|
+
* the mj_actions library for each user environment. The mj_actions library will have a class for each action and that class will have certain libraries imported at the top of the file and available for use.
|
|
43
|
+
* That information along with a detailed amount of system prompt steering goes into the AI model in order to generate contextually appropriate and reliable code that maps to the business logic of the user
|
|
44
|
+
*/
|
|
45
|
+
GenerateCode(maxAttempts?: number): Promise<GeneratedCode>;
|
|
46
|
+
protected InternalGenerateCode(llm: BaseLLM, chatParams: ChatParams, attemptsRemaining: number): Promise<GeneratedCode>;
|
|
47
|
+
GenerateSysPrompt(): string;
|
|
48
|
+
}
|
|
49
|
+
export declare function LoadActionEntityServer(): void;
|
|
50
|
+
//# sourceMappingURL=ActionEntity.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionEntity.server.d.ts","sourceRoot":"","sources":["../../src/generic/ActionEntity.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,UAAU,EAAE,iBAAiB,EAA+B,MAAM,sBAAsB,CAAC;AAClI,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAI7H,OAAO,EAA+B,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,UAAU,EAAe,MAAM,oBAAoB,CAAC;AAEtE;;GAEG;AACH,qBACa,wBAAyB,SAAQ,YAAY;gBAC1C,MAAM,EAAE,UAAU;IAO9B;;;OAGG;IACH,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;IAED;;OAEG;IACH,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,OAAO,CAEjC;IAED,OAAO,CAAC,YAAY,CAAkC;IACtD;;OAEG;IACH,IAAW,WAAW,IAAI,sBAAsB,EAAE,CAMjD;IAED,OAAO,CAAC,OAAO,CAA6B;IAC5C,IAAW,MAAM,IAAI,iBAAiB,EAAE,CAMvC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,IAAW,SAAS,IAAI,mBAAmB,EAAE,CAM5C;IAGD;;;;;OAKG;IACmB,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAkGzE,SAAS,CAAC,WAAW,CA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