@memberjunction/core-actions 5.29.0 → 5.30.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/dist/custom/ai/actionsmith-agent.d.ts +78 -0
- package/dist/custom/ai/actionsmith-agent.d.ts.map +1 -0
- package/dist/custom/ai/actionsmith-agent.js +373 -0
- package/dist/custom/ai/actionsmith-agent.js.map +1 -0
- package/dist/custom/ai/create-runtime-action.action.d.ts +32 -0
- package/dist/custom/ai/create-runtime-action.action.d.ts.map +1 -0
- package/dist/custom/ai/create-runtime-action.action.js +220 -0
- package/dist/custom/ai/create-runtime-action.action.js.map +1 -0
- package/dist/custom/ai/execute-agent.action.d.ts +45 -0
- package/dist/custom/ai/execute-agent.action.d.ts.map +1 -0
- package/dist/custom/ai/execute-agent.action.js +192 -0
- package/dist/custom/ai/execute-agent.action.js.map +1 -0
- package/dist/custom/ai/test-runtime-action.action.d.ts +37 -0
- package/dist/custom/ai/test-runtime-action.action.d.ts.map +1 -0
- package/dist/custom/ai/test-runtime-action.action.js +317 -0
- package/dist/custom/ai/test-runtime-action.action.js.map +1 -0
- package/dist/custom/data/get-entity-details.action.d.ts.map +1 -1
- package/dist/custom/data/get-entity-details.action.js +15 -2
- package/dist/custom/data/get-entity-details.action.js.map +1 -1
- package/dist/custom/data/get-entity-list.action.d.ts.map +1 -1
- package/dist/custom/data/get-entity-list.action.js +7 -2
- package/dist/custom/data/get-entity-list.action.js.map +1 -1
- package/dist/custom/lists/create-list.action.d.ts.map +1 -1
- package/dist/custom/lists/create-list.action.js +22 -29
- package/dist/custom/lists/create-list.action.js.map +1 -1
- package/dist/custom/lists/remove-records-from-list.action.d.ts.map +1 -1
- package/dist/custom/lists/remove-records-from-list.action.js +25 -29
- package/dist/custom/lists/remove-records-from-list.action.js.map +1 -1
- package/dist/custom/lists/update-list-item-status.action.d.ts.map +1 -1
- package/dist/custom/lists/update-list-item-status.action.js +25 -29
- package/dist/custom/lists/update-list-item-status.action.js.map +1 -1
- package/dist/custom/user-management/assign-user-roles.action.d.ts.map +1 -1
- package/dist/custom/user-management/assign-user-roles.action.js +25 -18
- package/dist/custom/user-management/assign-user-roles.action.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +29 -29
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { ActionParam } from '@memberjunction/actions-base';
|
|
8
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
9
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
10
|
+
import { LogError, Metadata } from '@memberjunction/core';
|
|
11
|
+
import { RuntimeActionConfigurationSchema } from '@memberjunction/actions-base';
|
|
12
|
+
/**
|
|
13
|
+
* Persists a new Runtime action to the Actions catalog with
|
|
14
|
+
* `CodeApprovalStatus='Pending'`. Used by the ActionSmith agent as the
|
|
15
|
+
* last step of the "generate, test, submit for approval" pipeline.
|
|
16
|
+
*
|
|
17
|
+
* Responsibilities:
|
|
18
|
+
* - Validate the supplied `RuntimeActionConfiguration` against the Zod
|
|
19
|
+
* schema — invalid configs are rejected before anything hits the DB.
|
|
20
|
+
* - Create the Action row with Type='Runtime', the author-agent link,
|
|
21
|
+
* and the JSON-serialized configuration stored via the generated
|
|
22
|
+
* `RuntimeActionConfigurationObject` accessor.
|
|
23
|
+
* - Create ActionParam rows for declared inputs and outputs.
|
|
24
|
+
* - Create ActionResultCode rows for declared result codes.
|
|
25
|
+
*
|
|
26
|
+
* The action record is NOT activated. `CodeApprovalStatus` is 'Pending'
|
|
27
|
+
* until a human reviews the code + permissions through the approval UI.
|
|
28
|
+
*/
|
|
29
|
+
let CreateRuntimeActionAction = class CreateRuntimeActionAction extends BaseAction {
|
|
30
|
+
async InternalRunAction(params) {
|
|
31
|
+
try {
|
|
32
|
+
const name = this.getStringParam(params, 'name');
|
|
33
|
+
const description = this.getStringParam(params, 'description');
|
|
34
|
+
const categoryId = this.getStringParam(params, 'categoryid');
|
|
35
|
+
const code = this.getStringParam(params, 'code');
|
|
36
|
+
const maxExecutionTimeMs = this.getNumericParam(params, 'maxexecutiontimems');
|
|
37
|
+
const createdByAgentId = this.getStringParam(params, 'createdbyagentid');
|
|
38
|
+
const config = this.getObjectParam(params, 'configuration');
|
|
39
|
+
const inputParams = this.getObjectParam(params, 'inputparams') ?? [];
|
|
40
|
+
const outputParams = this.getObjectParam(params, 'outputparams') ?? [];
|
|
41
|
+
const resultCodes = this.getObjectParam(params, 'resultcodes') ?? [];
|
|
42
|
+
if (!name) {
|
|
43
|
+
return fail('MISSING_NAME', 'Name is required to create a runtime action.');
|
|
44
|
+
}
|
|
45
|
+
if (!description) {
|
|
46
|
+
return fail('MISSING_DESCRIPTION', 'Description is required.');
|
|
47
|
+
}
|
|
48
|
+
if (!code) {
|
|
49
|
+
return fail('MISSING_CODE', 'Code is required.');
|
|
50
|
+
}
|
|
51
|
+
if (!config) {
|
|
52
|
+
return fail('MISSING_CONFIG', 'RuntimeActionConfiguration is required.');
|
|
53
|
+
}
|
|
54
|
+
const validated = RuntimeActionConfigurationSchema.safeParse(config);
|
|
55
|
+
if (!validated.success) {
|
|
56
|
+
return fail('INVALID_CONFIG', `RuntimeActionConfiguration failed validation: ${validated.error.message}`);
|
|
57
|
+
}
|
|
58
|
+
const md = new Metadata();
|
|
59
|
+
// Entity is registered as 'MJ: Actions' (see entity_subclasses.ts —
|
|
60
|
+
// newer MJ core entities use the 'MJ: ' prefix). Passing 'Actions'
|
|
61
|
+
// silently returned null, so every Create Runtime Action call
|
|
62
|
+
// failed with "Could not instantiate Actions entity" — this
|
|
63
|
+
// permanently blocked ActionSmith from persisting any action.
|
|
64
|
+
const action = await md.GetEntityObject('MJ: Actions', params.ContextUser);
|
|
65
|
+
if (!action) {
|
|
66
|
+
return fail('ENTITY_LOAD_FAILED', 'Could not instantiate MJ: Actions entity. Check that the entity exists and the context user has permission.');
|
|
67
|
+
}
|
|
68
|
+
action.NewRecord();
|
|
69
|
+
action.Name = name;
|
|
70
|
+
action.Description = description;
|
|
71
|
+
action.Type = 'Runtime';
|
|
72
|
+
action.Code = code;
|
|
73
|
+
action.CodeApprovalStatus = 'Pending';
|
|
74
|
+
action.Status = 'Active';
|
|
75
|
+
if (categoryId) {
|
|
76
|
+
action.CategoryID = categoryId;
|
|
77
|
+
}
|
|
78
|
+
if (maxExecutionTimeMs != null) {
|
|
79
|
+
action.MaxExecutionTimeMS = maxExecutionTimeMs;
|
|
80
|
+
}
|
|
81
|
+
if (createdByAgentId) {
|
|
82
|
+
action.CreatedByAgentID = createdByAgentId;
|
|
83
|
+
}
|
|
84
|
+
// Use the typed JSONType accessor emitted by CodeGen — this
|
|
85
|
+
// stringifies the config into RuntimeActionConfiguration behind
|
|
86
|
+
// the scenes and caches the parsed form for subsequent reads.
|
|
87
|
+
action.RuntimeActionConfigurationObject = validated.data;
|
|
88
|
+
const saved = await action.Save();
|
|
89
|
+
if (!saved) {
|
|
90
|
+
return fail('SAVE_FAILED', action.LatestResult?.CompleteMessage ?? `Failed to save action '${name}'.`);
|
|
91
|
+
}
|
|
92
|
+
for (const p of [...inputParams, ...outputParams]) {
|
|
93
|
+
const err = await this.createActionParam(md, params, action.ID, p);
|
|
94
|
+
if (err)
|
|
95
|
+
return err;
|
|
96
|
+
}
|
|
97
|
+
for (const rc of resultCodes) {
|
|
98
|
+
const err = await this.createResultCode(md, params, action.ID, rc);
|
|
99
|
+
if (err)
|
|
100
|
+
return err;
|
|
101
|
+
}
|
|
102
|
+
this.setOutputParam(params, 'ActionID', action.ID);
|
|
103
|
+
this.setOutputParam(params, 'Name', action.Name);
|
|
104
|
+
this.setOutputParam(params, 'CodeApprovalStatus', action.CodeApprovalStatus);
|
|
105
|
+
return {
|
|
106
|
+
Success: true,
|
|
107
|
+
ResultCode: 'SUCCESS',
|
|
108
|
+
Message: `Runtime action '${name}' created and awaiting approval.`,
|
|
109
|
+
Params: params.Params
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
114
|
+
LogError(`CreateRuntimeActionAction error: ${message}`);
|
|
115
|
+
return fail('UNEXPECTED_ERROR', message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async createActionParam(md, params, actionId, spec) {
|
|
119
|
+
const entity = await md.GetEntityObject('MJ: Action Params', params.ContextUser);
|
|
120
|
+
if (!entity) {
|
|
121
|
+
return fail('PARAM_ENTITY_FAILED', 'Could not instantiate Action Params entity.');
|
|
122
|
+
}
|
|
123
|
+
entity.NewRecord();
|
|
124
|
+
entity.ActionID = actionId;
|
|
125
|
+
entity.Name = spec.name;
|
|
126
|
+
entity.Type = spec.type;
|
|
127
|
+
entity.ValueType = spec.valueType ?? 'Scalar';
|
|
128
|
+
entity.IsArray = Boolean(spec.isArray);
|
|
129
|
+
entity.IsRequired = Boolean(spec.isRequired);
|
|
130
|
+
if (spec.description)
|
|
131
|
+
entity.Description = spec.description;
|
|
132
|
+
if (spec.defaultValue != null)
|
|
133
|
+
entity.DefaultValue = String(spec.defaultValue);
|
|
134
|
+
const saved = await entity.Save();
|
|
135
|
+
if (!saved) {
|
|
136
|
+
return fail('PARAM_SAVE_FAILED', entity.LatestResult?.CompleteMessage ?? `Failed to save param '${spec.name}'.`);
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
async createResultCode(md, params, actionId, spec) {
|
|
141
|
+
const entity = await md.GetEntityObject('MJ: Action Result Codes', params.ContextUser);
|
|
142
|
+
if (!entity) {
|
|
143
|
+
return fail('RESULT_CODE_ENTITY_FAILED', 'Could not instantiate Result Codes entity.');
|
|
144
|
+
}
|
|
145
|
+
entity.NewRecord();
|
|
146
|
+
entity.ActionID = actionId;
|
|
147
|
+
entity.ResultCode = spec.resultCode;
|
|
148
|
+
entity.IsSuccess = Boolean(spec.isSuccess);
|
|
149
|
+
if (spec.description)
|
|
150
|
+
entity.Description = spec.description;
|
|
151
|
+
const saved = await entity.Save();
|
|
152
|
+
if (!saved) {
|
|
153
|
+
return fail('RESULT_CODE_SAVE_FAILED', entity.LatestResult?.CompleteMessage ??
|
|
154
|
+
`Failed to save result code '${spec.resultCode}'.`);
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
// --- tiny local param helpers ------------------------------------------
|
|
159
|
+
getParamValue(params, name) {
|
|
160
|
+
const p = params.Params?.find((x) => x.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
161
|
+
return p?.Value;
|
|
162
|
+
}
|
|
163
|
+
getStringParam(params, name) {
|
|
164
|
+
const v = this.getParamValue(params, name);
|
|
165
|
+
if (v == null)
|
|
166
|
+
return undefined;
|
|
167
|
+
const s = String(v).trim();
|
|
168
|
+
return s.length ? s : undefined;
|
|
169
|
+
}
|
|
170
|
+
getNumericParam(params, name) {
|
|
171
|
+
const v = this.getParamValue(params, name);
|
|
172
|
+
if (v == null)
|
|
173
|
+
return undefined;
|
|
174
|
+
const n = Number(v);
|
|
175
|
+
return Number.isFinite(n) ? n : undefined;
|
|
176
|
+
}
|
|
177
|
+
getObjectParam(params, name) {
|
|
178
|
+
const v = this.getParamValue(params, name);
|
|
179
|
+
if (v == null)
|
|
180
|
+
return null;
|
|
181
|
+
if (typeof v === 'object')
|
|
182
|
+
return v;
|
|
183
|
+
if (typeof v === 'string') {
|
|
184
|
+
try {
|
|
185
|
+
return JSON.parse(v);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
setOutputParam(params, name, value) {
|
|
194
|
+
const existing = params.Params?.find((p) => p.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
195
|
+
if (existing) {
|
|
196
|
+
existing.Value = value;
|
|
197
|
+
existing.Type = existing.Type === 'Input' ? 'Both' : existing.Type || 'Output';
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!params.Params)
|
|
201
|
+
params.Params = [];
|
|
202
|
+
const p = new ActionParam();
|
|
203
|
+
p.Name = name;
|
|
204
|
+
p.Value = value;
|
|
205
|
+
p.Type = 'Output';
|
|
206
|
+
params.Params.push(p);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
CreateRuntimeActionAction = __decorate([
|
|
210
|
+
RegisterClass(BaseAction, 'Create Runtime Action')
|
|
211
|
+
], CreateRuntimeActionAction);
|
|
212
|
+
export { CreateRuntimeActionAction };
|
|
213
|
+
function fail(resultCode, message) {
|
|
214
|
+
return { Success: false, ResultCode: resultCode, Message: message };
|
|
215
|
+
}
|
|
216
|
+
/** Tree-shaking prevention hook called from the CoreActions public API. */
|
|
217
|
+
export function LoadCreateRuntimeActionAction() {
|
|
218
|
+
// intentionally empty
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=create-runtime-action.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-runtime-action.action.js","sourceRoot":"","sources":["../../../src/custom/ai/create-runtime-action.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAuC,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO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ED,2EAA2E;AAC3E,MAAM,UAAU,6BAA6B;IACzC,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
/**
|
|
4
|
+
* Action that executes any top-level AI Agent by name or ID.
|
|
5
|
+
*
|
|
6
|
+
* Serves two purposes:
|
|
7
|
+
* 1. External callers (schedulers, workflows, MCP clients, other Runtime
|
|
8
|
+
* actions invoking via `utilities.actions.Invoke`) can run agents through
|
|
9
|
+
* the uniform Action catalog instead of reaching for the AgentRunner API.
|
|
10
|
+
* 2. Gives us a concrete dispatch target for `AIAgent.ExposeAsAction` once
|
|
11
|
+
* the auto-registration pass lands — every exposed agent becomes callable
|
|
12
|
+
* as an action without a separate Custom class per agent.
|
|
13
|
+
*
|
|
14
|
+
* **Not used inside the Runtime Actions bridge.** Script code calling
|
|
15
|
+
* `utilities.agents.Run(...)` from the sandbox bridges back to the host which
|
|
16
|
+
* invokes `AgentRunner.RunAgent()` directly — skipping this wrapper because
|
|
17
|
+
* the bridge already runs in-process with `contextUser` and doesn't need the
|
|
18
|
+
* action-catalog indirection.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* await runAction({
|
|
23
|
+
* ActionName: 'Execute Agent',
|
|
24
|
+
* Params: [
|
|
25
|
+
* { Name: 'AgentName', Value: 'Customer Sentiment Analyzer', Type: 'Input' },
|
|
26
|
+
* { Name: 'ConversationMessages', Value: [{ role: 'user', content: 'Analyze ticket 12345' }], Type: 'Input' },
|
|
27
|
+
* { Name: 'Data', Value: { ticketId: '12345' }, Type: 'Input' }
|
|
28
|
+
* ]
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class ExecuteAgentAction extends BaseAction {
|
|
33
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
34
|
+
private getParamValue;
|
|
35
|
+
private getStringParam;
|
|
36
|
+
private getNumericParam;
|
|
37
|
+
private setOutputParam;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Tree-shaking prevention — importing this function forces the module to load
|
|
41
|
+
* and the `@RegisterClass` decorator to run. Called from CoreActions' public
|
|
42
|
+
* API barrel.
|
|
43
|
+
*/
|
|
44
|
+
export declare function LoadExecuteAgentAction(): void;
|
|
45
|
+
//# sourceMappingURL=execute-agent.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-agent.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/execute-agent.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBACa,kBAAmB,SAAQ,UAAU;cAC9B,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAuHvF,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,cAAc;CAkBzB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { ActionParam } from '@memberjunction/actions-base';
|
|
8
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
9
|
+
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
10
|
+
import { LogError } from '@memberjunction/core';
|
|
11
|
+
import { AgentRunner } from '@memberjunction/ai-agents';
|
|
12
|
+
import { AIEngine } from '@memberjunction/aiengine';
|
|
13
|
+
/**
|
|
14
|
+
* Action that executes any top-level AI Agent by name or ID.
|
|
15
|
+
*
|
|
16
|
+
* Serves two purposes:
|
|
17
|
+
* 1. External callers (schedulers, workflows, MCP clients, other Runtime
|
|
18
|
+
* actions invoking via `utilities.actions.Invoke`) can run agents through
|
|
19
|
+
* the uniform Action catalog instead of reaching for the AgentRunner API.
|
|
20
|
+
* 2. Gives us a concrete dispatch target for `AIAgent.ExposeAsAction` once
|
|
21
|
+
* the auto-registration pass lands — every exposed agent becomes callable
|
|
22
|
+
* as an action without a separate Custom class per agent.
|
|
23
|
+
*
|
|
24
|
+
* **Not used inside the Runtime Actions bridge.** Script code calling
|
|
25
|
+
* `utilities.agents.Run(...)` from the sandbox bridges back to the host which
|
|
26
|
+
* invokes `AgentRunner.RunAgent()` directly — skipping this wrapper because
|
|
27
|
+
* the bridge already runs in-process with `contextUser` and doesn't need the
|
|
28
|
+
* action-catalog indirection.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* await runAction({
|
|
33
|
+
* ActionName: 'Execute Agent',
|
|
34
|
+
* Params: [
|
|
35
|
+
* { Name: 'AgentName', Value: 'Customer Sentiment Analyzer', Type: 'Input' },
|
|
36
|
+
* { Name: 'ConversationMessages', Value: [{ role: 'user', content: 'Analyze ticket 12345' }], Type: 'Input' },
|
|
37
|
+
* { Name: 'Data', Value: { ticketId: '12345' }, Type: 'Input' }
|
|
38
|
+
* ]
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
let ExecuteAgentAction = class ExecuteAgentAction extends BaseAction {
|
|
43
|
+
async InternalRunAction(params) {
|
|
44
|
+
try {
|
|
45
|
+
// ---- Resolve agent ----
|
|
46
|
+
const agentID = this.getStringParam(params, 'agentid');
|
|
47
|
+
const agentName = this.getStringParam(params, 'agentname');
|
|
48
|
+
if (!agentID && !agentName) {
|
|
49
|
+
return {
|
|
50
|
+
Success: false,
|
|
51
|
+
ResultCode: 'MISSING_AGENT_IDENTIFIER',
|
|
52
|
+
Message: 'Execute Agent requires either AgentID or AgentName parameter.'
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Make sure AIEngine has agent metadata loaded before we look anything up.
|
|
56
|
+
await AIEngine.Instance.Config(false, params.ContextUser);
|
|
57
|
+
const agent = agentID
|
|
58
|
+
? AIEngine.Instance.Agents.find((a) => UUIDsEqual(a.ID, agentID))
|
|
59
|
+
: AIEngine.Instance.Agents.find((a) => a.Name?.trim().toLowerCase() === agentName.trim().toLowerCase());
|
|
60
|
+
if (!agent) {
|
|
61
|
+
return {
|
|
62
|
+
Success: false,
|
|
63
|
+
ResultCode: 'AGENT_NOT_FOUND',
|
|
64
|
+
Message: agentID
|
|
65
|
+
? `No agent found with ID '${agentID}'`
|
|
66
|
+
: `No agent found with name '${agentName}'`
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// Sub-agents (ParentID set) can't be exposed — their contract is
|
|
70
|
+
// governed by the parent; invoking them directly would bypass the
|
|
71
|
+
// parent agent's payload filtering.
|
|
72
|
+
if (agent.ParentID) {
|
|
73
|
+
return {
|
|
74
|
+
Success: false,
|
|
75
|
+
ResultCode: 'AGENT_IS_SUB_AGENT',
|
|
76
|
+
Message: `Agent '${agent.Name}' is a sub-agent (ParentID is set). ` +
|
|
77
|
+
'Only top-level agents can be invoked through Execute Agent. ' +
|
|
78
|
+
"Run the parent agent instead, or invoke this sub-agent via the parent's workflow."
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Only agents that the operator has explicitly flagged as callable
|
|
82
|
+
// from outside may be dispatched this way. This is the
|
|
83
|
+
// `ExposeAsAction` contract — once auto-registration lands, it
|
|
84
|
+
// will only create catalog entries for agents that pass this check.
|
|
85
|
+
if (!agent.ExposeAsAction) {
|
|
86
|
+
return {
|
|
87
|
+
Success: false,
|
|
88
|
+
ResultCode: 'AGENT_NOT_EXPOSED',
|
|
89
|
+
Message: `Agent '${agent.Name}' is not exposed as an action (AIAgent.ExposeAsAction=false). ` +
|
|
90
|
+
'Enable ExposeAsAction on the agent record to allow invocation via Execute Agent.'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// ---- Collect optional inputs ----
|
|
94
|
+
const conversationMessages = this.getParamValue(params, 'conversationmessages') ?? [];
|
|
95
|
+
const data = this.getParamValue(params, 'data');
|
|
96
|
+
const conversationDetailId = this.getStringParam(params, 'conversationdetailid');
|
|
97
|
+
const lastRunId = this.getStringParam(params, 'lastrunid');
|
|
98
|
+
const maxExecutionTimeMs = this.getNumericParam(params, 'maxexecutiontimems');
|
|
99
|
+
const runner = new AgentRunner();
|
|
100
|
+
const runResult = await runner.RunAgent({
|
|
101
|
+
agent: agent,
|
|
102
|
+
conversationMessages,
|
|
103
|
+
contextUser: params.ContextUser,
|
|
104
|
+
data,
|
|
105
|
+
conversationDetailId: conversationDetailId ?? undefined,
|
|
106
|
+
lastRunId: lastRunId ?? undefined,
|
|
107
|
+
maxExecutionTimeMs: maxExecutionTimeMs ?? undefined,
|
|
108
|
+
cancellationToken: params.AbortSignal
|
|
109
|
+
});
|
|
110
|
+
// ---- Expose outputs for downstream action consumers ----
|
|
111
|
+
this.setOutputParam(params, 'AgentRunID', runResult.agentRun?.ID ?? null);
|
|
112
|
+
this.setOutputParam(params, 'Payload', runResult.payload ?? null);
|
|
113
|
+
this.setOutputParam(params, 'AgentResult', runResult);
|
|
114
|
+
if (runResult.success) {
|
|
115
|
+
return {
|
|
116
|
+
Success: true,
|
|
117
|
+
ResultCode: 'SUCCESS',
|
|
118
|
+
Message: runResult.agentRun?.Message ?? 'Agent execution completed successfully.',
|
|
119
|
+
Params: params.Params
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
Success: false,
|
|
124
|
+
ResultCode: 'AGENT_EXECUTION_FAILED',
|
|
125
|
+
Message: runResult.agentRun?.Message ??
|
|
126
|
+
`Agent '${agent.Name}' execution did not complete successfully.`,
|
|
127
|
+
Params: params.Params
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
132
|
+
LogError(`ExecuteAgentAction error: ${message}`);
|
|
133
|
+
return {
|
|
134
|
+
Success: false,
|
|
135
|
+
ResultCode: 'UNEXPECTED_ERROR',
|
|
136
|
+
Message: `Error executing agent: ${message}`
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// ------------------------------------------------------------------------
|
|
141
|
+
// Parameter helpers — each action keeps its own to match the existing
|
|
142
|
+
// CoreActions convention (HTTP Request, Execute AI Prompt, etc.)
|
|
143
|
+
// ------------------------------------------------------------------------
|
|
144
|
+
getParamValue(params, name) {
|
|
145
|
+
const param = params.Params?.find((p) => p.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
146
|
+
return param?.Value;
|
|
147
|
+
}
|
|
148
|
+
getStringParam(params, name) {
|
|
149
|
+
const value = this.getParamValue(params, name);
|
|
150
|
+
if (value === undefined || value === null)
|
|
151
|
+
return undefined;
|
|
152
|
+
const str = String(value).trim();
|
|
153
|
+
return str.length > 0 ? str : undefined;
|
|
154
|
+
}
|
|
155
|
+
getNumericParam(params, name) {
|
|
156
|
+
const value = this.getParamValue(params, name);
|
|
157
|
+
if (value === undefined || value === null)
|
|
158
|
+
return undefined;
|
|
159
|
+
const num = Number(value);
|
|
160
|
+
return Number.isFinite(num) ? num : undefined;
|
|
161
|
+
}
|
|
162
|
+
setOutputParam(params, name, value) {
|
|
163
|
+
const existing = params.Params?.find((p) => p.Name?.trim().toLowerCase() === name.toLowerCase());
|
|
164
|
+
if (existing) {
|
|
165
|
+
existing.Value = value;
|
|
166
|
+
existing.Type = existing.Type === 'Input' ? 'Both' : existing.Type || 'Output';
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (!params.Params) {
|
|
170
|
+
params.Params = [];
|
|
171
|
+
}
|
|
172
|
+
const output = new ActionParam();
|
|
173
|
+
output.Name = name;
|
|
174
|
+
output.Value = value;
|
|
175
|
+
output.Type = 'Output';
|
|
176
|
+
params.Params.push(output);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
ExecuteAgentAction = __decorate([
|
|
181
|
+
RegisterClass(BaseAction, 'Execute Agent')
|
|
182
|
+
], ExecuteAgentAction);
|
|
183
|
+
export { ExecuteAgentAction };
|
|
184
|
+
/**
|
|
185
|
+
* Tree-shaking prevention — importing this function forces the module to load
|
|
186
|
+
* and the `@RegisterClass` decorator to run. Called from CoreActions' public
|
|
187
|
+
* API barrel.
|
|
188
|
+
*/
|
|
189
|
+
export function LoadExecuteAgentAction() {
|
|
190
|
+
// intentionally empty
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=execute-agent.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-agent.action.js","sourceRoot":"","sources":["../../../src/custom/ai/execute-agent.action.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAuC,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,M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AAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAC7D,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACX,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;YACvB,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC;QACnF,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACjB,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;YACvB,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YACjC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;YACnB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;YACrB,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;YACvB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ,CAAA;AA7JY,kBAAkB;IAD9B,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC;GAC9B,kBAAkB,CA6J9B;;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IAClC,sBAAsB;AAC1B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
3
|
+
/**
|
|
4
|
+
* Executes a Runtime action against one or more test cases and returns
|
|
5
|
+
* per-case pass/fail results. Used by ActionSmith before submitting an
|
|
6
|
+
* action for human approval — if any case fails, ActionSmith iterates with
|
|
7
|
+
* Codesmith to refine the code.
|
|
8
|
+
*
|
|
9
|
+
* The action being tested can be:
|
|
10
|
+
* - An existing Runtime action record (identified by ActionID or Name)
|
|
11
|
+
* - A freshly-generated code payload that hasn't been persisted yet
|
|
12
|
+
* (Code + RuntimeActionConfiguration passed directly, no DB record
|
|
13
|
+
* required). This path uses a throwaway in-memory MJActionEntity with
|
|
14
|
+
* CodeApprovalStatus='Approved' so the executor permits it.
|
|
15
|
+
*
|
|
16
|
+
* Test cases are evaluated in sequence; expected outputs (if provided) are
|
|
17
|
+
* compared to actual outputs with structural deep equality.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TestRuntimeActionAction extends BaseAction {
|
|
20
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
21
|
+
private resolveExistingAction;
|
|
22
|
+
/**
|
|
23
|
+
* Builds an in-memory MJActionEntity instance pre-populated with the
|
|
24
|
+
* supplied inline code + config, flagged as Approved so the executor's
|
|
25
|
+
* approval gate lets it through. This record is NOT saved — it only
|
|
26
|
+
* exists for the duration of this action.
|
|
27
|
+
*/
|
|
28
|
+
private buildEphemeralAction;
|
|
29
|
+
private runCase;
|
|
30
|
+
private getParamValue;
|
|
31
|
+
private getStringParam;
|
|
32
|
+
private getObjectParam;
|
|
33
|
+
private setOutputParam;
|
|
34
|
+
}
|
|
35
|
+
/** Tree-shaking prevention hook called from the CoreActions public API. */
|
|
36
|
+
export declare function LoadTestRuntimeActionAction(): void;
|
|
37
|
+
//# sourceMappingURL=test-runtime-action.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runtime-action.action.d.ts","sourceRoot":"","sources":["../../../src/custom/ai/test-runtime-action.action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD;;;;;;;;;;;;;;;GAeG;AACH,qBACa,uBAAwB,SAAQ,UAAU;cACnC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAkGzE,qBAAqB;IAqBnC;;;;;OAKG;YACW,oBAAoB;YAuBpB,OAAO;IA2DrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,cAAc;CAczB;AAyFD,2EAA2E;AAC3E,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
|