plugin-agent-orchestrator 1.0.27 → 1.0.32
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 +9 -7
- package/dist/client/index.js +1 -1
- package/dist/client-v2/{214.723affb37c13bf7a.js → 214.79650a549273f163.js} +1 -1
- package/dist/client-v2/264.718a107e43fc163c.js +10 -0
- package/dist/client-v2/373.f5d5292e53c4e832.js +10 -0
- package/dist/client-v2/{41.1805b2edfaa4afe2.js → 41.ba6e080cc0488143.js} +1 -1
- package/dist/client-v2/418.29e713f79131eece.js +10 -0
- package/dist/client-v2/619.bd3c5698b40705c3.js +10 -0
- package/dist/client-v2/677.a991ce0250ff5c77.js +10 -0
- package/dist/client-v2/{70.a15d7fcec7c41768.js → 70.bda9518881c05360.js} +1 -1
- package/dist/client-v2/925.f5370de8f6632d65.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +7 -10
- package/dist/locale/en-US.json +94 -25
- package/dist/locale/vi-VN.json +94 -25
- package/dist/locale/zh-CN.json +94 -25
- package/dist/server/collections/agent-execution-spans.js +37 -0
- package/dist/server/collections/agent-harness-profiles.js +2 -2
- package/dist/server/collections/agent-memory-contexts.js +125 -0
- package/dist/server/collections/orchestrator-logs.js +2 -2
- package/dist/server/migrations/20260425000000-add-interaction-schema.js +3 -1
- package/dist/server/migrations/20260427000000-change-packages-to-text.js +3 -1
- package/dist/server/migrations/20260427000001-change-other-json-to-text.js +6 -2
- package/dist/server/migrations/20260524001000-add-plan-approval-and-harness-profiles.js +21 -19
- package/dist/server/migrations/20260621000000-native-policy-profile-defaults.js +193 -0
- package/dist/server/plugin.js +128 -74
- package/dist/server/resources/agent-monitor.js +454 -0
- package/dist/server/services/AgentHarness.js +24 -499
- package/dist/server/services/AgentMemoryContextService.js +216 -0
- package/dist/server/services/ExecutionSpanService.js +2 -2
- package/dist/server/services/NativeSubAgentObserver.js +413 -0
- package/dist/server/skill-hub/mcp/McpController.js +16 -5
- package/dist/server/skill-hub/plugin.js +81 -5
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +9 -3
- package/dist/server/tools/delegate-task.js +11 -589
- package/dist/server/utils/skill-settings.js +18 -1
- package/package.json +47 -49
- package/src/client/AIEmployeesContext.tsx +5 -18
- package/src/client/AgentRunsTab.tsx +2 -771
- package/src/client/HarnessProfilesTab.tsx +2 -257
- package/src/client/OrchestratorSettings.tsx +97 -106
- package/src/client/RulesTab.tsx +2 -788
- package/src/client/plugin.tsx +0 -2
- package/src/client/skill-hub/components/ExecutionHistory.tsx +200 -202
- package/src/client/skill-hub/components/ExecutionProgress.tsx +51 -55
- package/src/client/skill-hub/components/LoopSettings.tsx +331 -331
- package/src/client/skill-hub/components/SkillEditor.tsx +43 -39
- package/src/client/skill-hub/components/SkillManager.tsx +194 -181
- package/src/client/skill-hub/components/SkillTestPanel.tsx +141 -145
- package/src/client/skill-hub/locale.ts +16 -16
- package/src/client/skill-hub/tools/SkillHubCard.tsx +104 -109
- package/src/client/skill-hub/tools/loopTemplates.ts +52 -52
- package/src/client/skill-hub/utils/jsonFields.ts +7 -3
- package/src/client-v2/components/AIEmployeesContext.tsx +3 -16
- package/src/client-v2/components/AgentRunsTab.tsx +182 -455
- package/src/client-v2/components/HarnessProfilesTab.tsx +34 -31
- package/src/client-v2/components/RulesTab.tsx +2 -782
- package/src/client-v2/components/TracingTab.tsx +1 -1
- package/src/client-v2/hooks/useApiRequest.ts +8 -1
- package/src/client-v2/pages/RulesPage.tsx +2 -2
- package/src/client-v2/plugin.tsx +3 -3
- package/src/locale/en-US.json +94 -25
- package/src/locale/vi-VN.json +94 -25
- package/src/locale/zh-CN.json +94 -25
- package/src/server/__tests__/native-sub-agent-observer.test.ts +246 -0
- package/src/server/__tests__/skill-settings.test.ts +6 -6
- package/src/server/__tests__/smoke.test.ts +1 -0
- package/src/server/collections/agent-execution-spans.ts +37 -0
- package/src/server/collections/agent-harness-profiles.ts +59 -59
- package/src/server/collections/agent-loop-events.ts +71 -71
- package/src/server/collections/agent-loop-steps.ts +144 -144
- package/src/server/collections/agent-memory-contexts.ts +95 -0
- package/src/server/collections/orchestrator-logs.ts +4 -4
- package/src/server/collections/skill-definitions.ts +111 -111
- package/src/server/collections/skill-executions.ts +106 -106
- package/src/server/collections/skill-loop-configs.ts +65 -65
- package/src/server/migrations/20260423000000-add-progress-fields.ts +14 -14
- package/src/server/migrations/20260425000000-add-interaction-schema.ts +3 -1
- package/src/server/migrations/20260427000000-change-packages-to-text.ts +4 -2
- package/src/server/migrations/20260427000001-change-other-json-to-text.ts +9 -5
- package/src/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.ts +30 -30
- package/src/server/migrations/20260524001000-add-plan-approval-and-harness-profiles.ts +145 -142
- package/src/server/migrations/20260615000000-normalize-ai-employee-tool-bindings.ts +2 -2
- package/src/server/migrations/20260621000000-native-policy-profile-defaults.ts +193 -0
- package/src/server/plugin.ts +151 -94
- package/src/server/resources/agent-monitor.ts +482 -0
- package/src/server/services/AgentHarness.ts +38 -623
- package/src/server/services/AgentMemoryContextService.ts +256 -0
- package/src/server/services/AgentPlanValidator.ts +73 -73
- package/src/server/services/ExecutionSpanService.ts +6 -2
- package/src/server/services/FileManager.ts +144 -144
- package/src/server/services/NativeSubAgentObserver.ts +507 -0
- package/src/server/services/SkillManager.ts +583 -583
- package/src/server/services/SkillRepositoryService.ts +5 -7
- package/src/server/services/TokenTracker.ts +3 -3
- package/src/server/services/WorkerEnvManager.ts +1 -2
- package/src/server/skill-hub/actions/git-import.ts +5 -7
- package/src/server/skill-hub/mcp/McpController.ts +41 -14
- package/src/server/skill-hub/plugin.ts +89 -6
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +470 -460
- package/src/server/skill-hub/utils/json-fields.ts +1 -1
- package/src/server/tools/delegate-task.ts +13 -847
- package/src/server/utils/skill-settings.ts +24 -6
- package/dist/client-v2/264.0533912e6c5ea2d7.js +0 -10
- package/dist/client-v2/418.5ae055abf141820e.js +0 -10
- package/dist/client-v2/619.d99d3c9e61c99064.js +0 -10
- package/dist/client-v2/892.72db4161511c8a16.js +0 -10
- package/dist/client-v2/926.87f660b670d85bcc.js +0 -10
- package/src/client/tools/PlanApprovalCard.tsx +0 -176
- package/src/client/tools/registerOrchestratorCards.ts +0 -17
package/dist/server/plugin.js
CHANGED
|
@@ -42,22 +42,119 @@ __export(plugin_exports, {
|
|
|
42
42
|
module.exports = __toCommonJS(plugin_exports);
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
44
|
var import_path = __toESM(require("path"));
|
|
45
|
-
var import_delegate_task = require("./tools/delegate-task");
|
|
46
45
|
var import_external_rag_search = require("./tools/external-rag-search");
|
|
47
|
-
var import_orchestrator_plan = require("./tools/orchestrator-plan");
|
|
48
46
|
var import_tracing = require("./resources/tracing");
|
|
49
|
-
var
|
|
50
|
-
var import_RunEventBus = require("./services/RunEventBus");
|
|
47
|
+
var import_agent_monitor = require("./resources/agent-monitor");
|
|
51
48
|
var import_plugin = __toESM(require("./skill-hub/plugin"));
|
|
52
|
-
var
|
|
49
|
+
var import_NativeSubAgentObserver = require("./services/NativeSubAgentObserver");
|
|
53
50
|
var import_ctx_utils = require("./utils/ctx-utils");
|
|
54
51
|
var import_ai_manager = require("./utils/ai-manager");
|
|
52
|
+
function normalizeOptionalString(value) {
|
|
53
|
+
return typeof value === "string" ? value.trim() : "";
|
|
54
|
+
}
|
|
55
|
+
function readModelValue(record, key) {
|
|
56
|
+
const model = record;
|
|
57
|
+
return typeof (model == null ? void 0 : model.get) === "function" ? model.get(key) : model == null ? void 0 : model[key];
|
|
58
|
+
}
|
|
59
|
+
function buildAgentMemoryContextKey(values) {
|
|
60
|
+
const userPart = values.scope === "public" ? "public" : String(values.userId || "");
|
|
61
|
+
const agentPart = values.aiEmployeeUsername || "*";
|
|
62
|
+
return `${values.scope}:${userPart}:${agentPart}`;
|
|
63
|
+
}
|
|
64
|
+
async function validateAgentMemoryContextValues(ctx) {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
66
|
+
const actionName = (_a = ctx.action) == null ? void 0 : _a.actionName;
|
|
67
|
+
const values = ((_c = (_b = ctx.action) == null ? void 0 : _b.params) == null ? void 0 : _c.values) || {};
|
|
68
|
+
let nextValues = values;
|
|
69
|
+
let currentId = (_e = (_d = ctx.action) == null ? void 0 : _d.params) == null ? void 0 : _e.filterByTk;
|
|
70
|
+
if (actionName === "update" && ((_g = (_f = ctx.action) == null ? void 0 : _f.params) == null ? void 0 : _g.filterByTk)) {
|
|
71
|
+
const existing = await ctx.db.getRepository("agentMemoryContexts").findOne({
|
|
72
|
+
filter: { id: ctx.action.params.filterByTk }
|
|
73
|
+
});
|
|
74
|
+
currentId = readModelValue(existing, "id") || currentId;
|
|
75
|
+
nextValues = {
|
|
76
|
+
...((_h = existing == null ? void 0 : existing.toJSON) == null ? void 0 : _h.call(existing)) || existing || {},
|
|
77
|
+
...values
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const scope = normalizeOptionalString(nextValues.scope);
|
|
81
|
+
const userId = nextValues.userId;
|
|
82
|
+
const aiEmployeeUsername = normalizeOptionalString(nextValues.aiEmployeeUsername);
|
|
83
|
+
if (!["public", "user", "agent_user"].includes(scope)) {
|
|
84
|
+
ctx.throw(400, "scope must be one of: public, user, agent_user.");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (scope === "public" && userId != null && userId !== "") {
|
|
88
|
+
ctx.throw(400, 'scope="public" requires userId to be empty.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if ((scope === "user" || scope === "agent_user") && (userId == null || userId === "")) {
|
|
92
|
+
ctx.throw(400, `scope="${scope}" requires userId.`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (scope === "agent_user" && !aiEmployeeUsername) {
|
|
96
|
+
ctx.throw(400, 'scope="agent_user" requires aiEmployeeUsername.');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const normalizedValues = {
|
|
100
|
+
...values,
|
|
101
|
+
scope,
|
|
102
|
+
userId: scope === "public" ? null : userId,
|
|
103
|
+
aiEmployeeUsername,
|
|
104
|
+
contextKey: buildAgentMemoryContextKey({
|
|
105
|
+
scope,
|
|
106
|
+
userId: scope === "public" ? null : userId,
|
|
107
|
+
aiEmployeeUsername
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
const repo = ctx.db.getRepository("agentMemoryContexts");
|
|
111
|
+
const duplicate = await repo.findOne({
|
|
112
|
+
filter: { contextKey: normalizedValues.contextKey }
|
|
113
|
+
}) || await repo.findOne({
|
|
114
|
+
filter: {
|
|
115
|
+
scope,
|
|
116
|
+
userId: normalizedValues.userId,
|
|
117
|
+
aiEmployeeUsername
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const duplicateId = readModelValue(duplicate, "id");
|
|
121
|
+
if (duplicateId && String(duplicateId) !== String(currentId || "")) {
|
|
122
|
+
ctx.throw(400, "An agent memory context already exists for this scope, user, and AI employee.");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
ctx.action.params.values = normalizedValues;
|
|
126
|
+
}
|
|
127
|
+
async function resolveTracingRetentionDays(plugin) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
const envDays = Number(process.env.ORCHESTRATOR_LOG_RETENTION_DAYS);
|
|
130
|
+
if (Number.isFinite(envDays) && envDays > 0) return envDays;
|
|
131
|
+
try {
|
|
132
|
+
const defaultProfile = await plugin.db.getRepository("agentHarnessProfiles").findOne({
|
|
133
|
+
filter: {
|
|
134
|
+
tag: "default",
|
|
135
|
+
enabled: true
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const settings = (0, import_ctx_utils.asObject)(readModelValue(defaultProfile, "settings"));
|
|
139
|
+
const profileDays = Number(settings.tracingRetentionDays);
|
|
140
|
+
if (Number.isFinite(profileDays) && profileDays > 0) {
|
|
141
|
+
return profileDays;
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
(_b = (_a = plugin.app.logger) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(_a, "[AgentOrchestrator] Failed to load tracing retention policy", error);
|
|
145
|
+
}
|
|
146
|
+
return 30;
|
|
147
|
+
}
|
|
55
148
|
class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
56
149
|
skillHub;
|
|
57
|
-
|
|
150
|
+
nativeObserver;
|
|
151
|
+
installNativeObserver = () => {
|
|
152
|
+
var _a;
|
|
153
|
+
(_a = this.nativeObserver) == null ? void 0 : _a.install();
|
|
154
|
+
};
|
|
58
155
|
async afterAdd() {
|
|
59
156
|
this.skillHub = new import_plugin.default(this);
|
|
60
|
-
this.
|
|
157
|
+
this.nativeObserver = new import_NativeSubAgentObserver.NativeSubAgentObserver(this);
|
|
61
158
|
}
|
|
62
159
|
async beforeLoad() {
|
|
63
160
|
this.db.import({ directory: import_path.default.resolve(__dirname, "collections") });
|
|
@@ -68,17 +165,18 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
68
165
|
});
|
|
69
166
|
}
|
|
70
167
|
async load() {
|
|
168
|
+
var _a, _b;
|
|
71
169
|
await this.skillHub.load();
|
|
72
170
|
this.app.acl.registerSnippet({
|
|
73
171
|
name: `pm.${this.name}`,
|
|
74
172
|
actions: [
|
|
75
173
|
"orchestratorConfig:*",
|
|
76
174
|
"orchestratorTracing:*",
|
|
77
|
-
"
|
|
175
|
+
"agentMonitor:*",
|
|
176
|
+
"agentMemoryContexts:*",
|
|
78
177
|
"agentLoopRuns:*",
|
|
79
178
|
"agentLoopSteps:*",
|
|
80
179
|
"agentLoopEvents:*",
|
|
81
|
-
"agentLoopEventsStream:*",
|
|
82
180
|
"agentHarnessProfiles:*",
|
|
83
181
|
"agentExecutionSpans:*",
|
|
84
182
|
"skillDefinitions:*",
|
|
@@ -97,6 +195,7 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
97
195
|
this.app.acl.allow("skillHub", "test", "loggedIn");
|
|
98
196
|
this.app.acl.allow("skillHub", "download", "loggedIn");
|
|
99
197
|
this.app.acl.allow("skillHub", "listTemplates", "loggedIn");
|
|
198
|
+
this.app.acl.allow("agentMonitor", ["list", "get"], "loggedIn");
|
|
100
199
|
this.app.resourceManager.use(
|
|
101
200
|
async (ctx, next) => {
|
|
102
201
|
const { resourceName, actionName } = ctx.action || {};
|
|
@@ -111,78 +210,27 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
111
210
|
},
|
|
112
211
|
{ tag: "orchestrator-skill-executions-scope", after: "acl" }
|
|
113
212
|
);
|
|
213
|
+
this.app.resourceManager.use(
|
|
214
|
+
async (ctx, next) => {
|
|
215
|
+
const { resourceName, actionName } = ctx.action || {};
|
|
216
|
+
if (resourceName === "agentMemoryContexts" && (actionName === "create" || actionName === "update")) {
|
|
217
|
+
await validateAgentMemoryContextValues(ctx);
|
|
218
|
+
}
|
|
219
|
+
await next();
|
|
220
|
+
},
|
|
221
|
+
{ tag: "orchestrator-agent-memory-context-policy", after: "acl" }
|
|
222
|
+
);
|
|
114
223
|
const toolsManager = (0, import_ai_manager.getAIToolsManager)(this.app);
|
|
115
|
-
toolsManager.registerTools((0, import_orchestrator_plan.createOrchestratorPlanTools)(this, this.agentLoopService));
|
|
116
224
|
toolsManager.registerTools((0, import_external_rag_search.createExternalRagSearchTool)(this));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.app.
|
|
120
|
-
name: "agentLoopEventsStream",
|
|
121
|
-
actions: {
|
|
122
|
-
async stream(ctx, next) {
|
|
123
|
-
var _a, _b, _c;
|
|
124
|
-
const runId = ((_a = ctx.action.params) == null ? void 0 : _a.runId) || ((_b = ctx.query) == null ? void 0 : _b.runId) || ((_c = ctx.request.query) == null ? void 0 : _c.runId);
|
|
125
|
-
if (!runId) {
|
|
126
|
-
ctx.throw(400, "runId query parameter is required.");
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (!(0, import_ctx_utils.isAdminUser)(ctx)) {
|
|
130
|
-
const userId = (0, import_ctx_utils.currentUserId)(ctx);
|
|
131
|
-
const run = await ctx.db.getRepository("agentLoopRuns").findOne({
|
|
132
|
-
filter: { id: runId }
|
|
133
|
-
});
|
|
134
|
-
if (!run) {
|
|
135
|
-
ctx.throw(404, "Run not found.");
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const ownerId = run.get ? run.get("userId") : run.userId;
|
|
139
|
-
if (!userId || String(ownerId) !== String(userId)) {
|
|
140
|
-
ctx.throw(403, "You cannot stream events for this run.");
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
ctx.type = "text/event-stream";
|
|
145
|
-
ctx.set("Cache-Control", "no-cache");
|
|
146
|
-
ctx.set("Connection", "keep-alive");
|
|
147
|
-
ctx.set("X-Accel-Buffering", "no");
|
|
148
|
-
const unsubscribe = (0, import_RunEventBus.getRunEventBus)().subscribe(runId, (event) => {
|
|
149
|
-
try {
|
|
150
|
-
ctx.res.write(`data: ${JSON.stringify(event)}
|
|
151
|
-
|
|
152
|
-
`);
|
|
153
|
-
} catch {
|
|
154
|
-
unsubscribe();
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
const keepalive = setInterval(() => {
|
|
158
|
-
try {
|
|
159
|
-
ctx.res.write(": keepalive\n\n");
|
|
160
|
-
} catch {
|
|
161
|
-
clearInterval(keepalive);
|
|
162
|
-
unsubscribe();
|
|
163
|
-
}
|
|
164
|
-
}, 15e3);
|
|
165
|
-
ctx.req.on("close", () => {
|
|
166
|
-
clearInterval(keepalive);
|
|
167
|
-
unsubscribe();
|
|
168
|
-
});
|
|
169
|
-
ctx.req.on("error", () => {
|
|
170
|
-
clearInterval(keepalive);
|
|
171
|
-
unsubscribe();
|
|
172
|
-
});
|
|
173
|
-
ctx.res.writeHead(200);
|
|
174
|
-
ctx.res.write(": connected\n\n");
|
|
175
|
-
await next();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
});
|
|
225
|
+
(0, import_agent_monitor.registerAgentMonitorResource)(this);
|
|
226
|
+
this.installNativeObserver();
|
|
227
|
+
(_b = (_a = this.app).on) == null ? void 0 : _b.call(_a, "afterStart", this.installNativeObserver);
|
|
179
228
|
(0, import_tracing.registerTracingResource)(this);
|
|
180
229
|
this.app.cronJobManager.addJob({
|
|
181
230
|
cronTime: "0 30 2 * * *",
|
|
182
231
|
onTick: async () => {
|
|
183
232
|
try {
|
|
184
|
-
const days =
|
|
185
|
-
if (!Number.isFinite(days) || days <= 0) return;
|
|
233
|
+
const days = await resolveTracingRetentionDays(this);
|
|
186
234
|
const cutoff = new Date(Date.now() - days * 864e5);
|
|
187
235
|
const repo = this.db.getRepository("orchestratorLogs");
|
|
188
236
|
const spansRepo = this.db.getRepository("agentExecutionSpans");
|
|
@@ -207,10 +255,16 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
|
|
|
207
255
|
async afterEnable() {
|
|
208
256
|
}
|
|
209
257
|
async afterDisable() {
|
|
258
|
+
var _a;
|
|
259
|
+
(_a = this.nativeObserver) == null ? void 0 : _a.uninstall();
|
|
210
260
|
}
|
|
211
261
|
async remove() {
|
|
212
262
|
}
|
|
213
263
|
async beforeStop() {
|
|
264
|
+
var _a, _b, _c, _d, _e;
|
|
265
|
+
(_b = (_a = this.app).off) == null ? void 0 : _b.call(_a, "afterStart", this.installNativeObserver);
|
|
266
|
+
(_d = (_c = this.app).removeListener) == null ? void 0 : _d.call(_c, "afterStart", this.installNativeObserver);
|
|
267
|
+
(_e = this.nativeObserver) == null ? void 0 : _e.uninstall();
|
|
214
268
|
await this.skillHub.beforeStop();
|
|
215
269
|
}
|
|
216
270
|
}
|