plugin-agent-orchestrator 1.1.4 → 1.1.5
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 +204 -114
- package/dist/client/index.js +1 -1
- package/dist/client-v2/117.7565cff57c39318a.js +10 -0
- package/dist/client-v2/214.106635011859dede.js +10 -0
- package/dist/client-v2/418.41ed200e7d6da332.js +10 -0
- package/dist/client-v2/53.349fff8db80b19d4.js +10 -0
- package/dist/client-v2/981.e4a1f41cfc94a856.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +7 -8
- package/dist/locale/en-US.json +226 -170
- package/dist/locale/vi-VN.json +226 -170
- package/dist/locale/zh-CN.json +226 -170
- package/dist/server/collections/agent-execution-spans.js +8 -0
- package/dist/server/collections/agent-loop-action-approvals.js +1 -0
- package/dist/server/collections/agent-loop-runs.js +7 -1
- package/dist/server/collections/agent-loop-steps.js +7 -0
- package/dist/server/collections/skill-executions.js +8 -0
- package/dist/server/plugin.js +3 -1
- package/dist/server/resources/agent-harness-profile.js +117 -0
- package/dist/server/resources/agent-knowledge-insights.js +1 -3
- package/dist/server/resources/agent-loop-approval.js +25 -0
- package/dist/server/resources/agent-loop.js +3 -1
- package/dist/server/services/AgentMemoryContextService.js +34 -0
- package/dist/server/services/HarnessCompiler.js +35 -2
- package/dist/server/services/HarnessProfileService.js +74 -9
- package/dist/server/services/HarnessSchema.js +30 -3
- package/dist/server/services/LoopPatternSchema.js +16 -1
- package/dist/server/services/LoopRunRepository.js +80 -0
- package/dist/server/services/LoopRunStateMachine.js +92 -3
- package/dist/server/services/LoopTriggerService.js +37 -0
- package/dist/server/services/LoopWorkerService.js +261 -23
- package/dist/server/services/NativeSubAgentObserver.js +165 -23
- package/dist/server/services/PluginAiRuntimeAdapter.js +16 -5
- package/dist/server/services/ToolLoopDetectionService.js +210 -0
- package/dist/server/services/VerificationService.js +66 -0
- package/dist/server/services/harness-runtime-policy.js +139 -0
- package/dist/server/skill-hub/plugin.js +36 -3
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +29 -0
- package/package.json +53 -53
- package/src/client/ApprovalsTab.tsx +2 -0
- package/src/client/OrchestratorSettings.tsx +11 -0
- package/src/client/skill-hub/components/GitSkillImport.tsx +3 -3
- package/src/client/skill-hub/components/SkillMetrics.tsx +15 -10
- package/src/client/skill-hub/index.tsx +0 -52
- package/src/client-v2/components/AgentRunsTab.tsx +576 -576
- package/src/client-v2/components/ApprovalsTab.tsx +337 -0
- package/src/client-v2/components/HarnessProfilesTab.tsx +385 -105
- package/src/client-v2/components/MemoryInspectorTab.tsx +141 -141
- package/src/client-v2/components/TracingTab.tsx +515 -515
- package/src/client-v2/hooks/useApiRequest.ts +141 -141
- package/src/client-v2/pages/ApprovalsPage.tsx +10 -0
- package/src/client-v2/plugin.tsx +6 -6
- package/src/client-v2/skill-hub/components/SkillMetrics.tsx +5 -2
- package/src/locale/en-US.json +226 -174
- package/src/locale/vi-VN.json +226 -174
- package/src/locale/zh-CN.json +226 -174
- package/src/server/__tests__/circuit-breaker.test.ts +248 -248
- package/src/server/__tests__/harness-compiler.test.ts +83 -0
- package/src/server/__tests__/harness-profile-service.test.ts +51 -0
- package/src/server/__tests__/harness-runtime-policy.test.ts +293 -0
- package/src/server/__tests__/harness-tool-plan.test.ts +24 -0
- package/src/server/__tests__/loop-approval-decision.test.ts +512 -0
- package/src/server/__tests__/loop-approval-expiry.test.ts +258 -0
- package/src/server/__tests__/loop-budget-service.test.ts +255 -255
- package/src/server/__tests__/loop-control-plane-backfill.test.ts +266 -266
- package/src/server/__tests__/loop-pattern-schema.test.ts +18 -1
- package/src/server/__tests__/loop-pattern-service.test.ts +148 -148
- package/src/server/__tests__/loop-run-state-machine.test.ts +11 -0
- package/src/server/__tests__/loop-trigger-service.test.ts +148 -0
- package/src/server/__tests__/loop-worker-claim.test.ts +341 -341
- package/src/server/__tests__/loop-worker-execution.test.ts +82 -1
- package/src/server/__tests__/native-sub-agent-observer.test.ts +288 -4
- package/src/server/__tests__/path-lock-service.test.ts +254 -254
- package/src/server/__tests__/skill-execution-task-policy.test.ts +140 -0
- package/src/server/__tests__/smoke.test.ts +162 -162
- package/src/server/__tests__/tool-loop-detection.test.ts +275 -0
- package/src/server/collections/agent-execution-spans.ts +8 -0
- package/src/server/collections/agent-harness-profile-versions.ts +26 -26
- package/src/server/collections/agent-harness-profiles.ts +71 -71
- package/src/server/collections/agent-loop-action-approvals.ts +1 -0
- package/src/server/collections/agent-loop-artifacts.ts +25 -25
- package/src/server/collections/agent-loop-circuit-states.ts +23 -23
- package/src/server/collections/agent-loop-control-settings.ts +21 -21
- package/src/server/collections/agent-loop-events.ts +98 -98
- package/src/server/collections/agent-loop-path-locks.ts +27 -27
- package/src/server/collections/agent-loop-patterns.ts +42 -42
- package/src/server/collections/agent-loop-runs.ts +7 -1
- package/src/server/collections/agent-loop-steps.ts +7 -0
- package/src/server/collections/agent-loop-usage-buckets.ts +22 -22
- package/src/server/collections/agent-loop-worktrees.ts +25 -25
- package/src/server/collections/skill-executions.ts +8 -0
- package/src/server/migrations/20260427000002-change-packages-to-text.ts +52 -52
- package/src/server/migrations/20260429000000-add-llm-fields.ts +47 -47
- package/src/server/migrations/20260429000001-fix-inputargs-json-to-text.ts +45 -45
- package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +33 -33
- package/src/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.ts +31 -31
- package/src/server/migrations/20260803010000-backfill-loop-control-plane-data.ts +293 -293
- package/src/server/plugin.ts +3 -1
- package/src/server/resources/agent-harness-profile.ts +94 -0
- package/src/server/resources/agent-knowledge-insights.ts +5 -3
- package/src/server/resources/agent-loop-approval.ts +32 -0
- package/src/server/resources/agent-loop-artifact.ts +56 -56
- package/src/server/resources/agent-loop-events-stream.ts +105 -105
- package/src/server/resources/agent-loop.ts +3 -1
- package/src/server/resources/resource-helpers.ts +33 -33
- package/src/server/resources/tracing.ts +266 -266
- package/src/server/services/AgentMemoryContextService.ts +44 -0
- package/src/server/services/DurableCircuitBreakerService.ts +239 -239
- package/src/server/services/ExecutionSpanService.ts +2 -0
- package/src/server/services/HarnessCompiler.ts +37 -0
- package/src/server/services/HarnessProfileService.ts +92 -10
- package/src/server/services/HarnessSchema.ts +31 -0
- package/src/server/services/LoopBudgetService.ts +275 -275
- package/src/server/services/LoopControlService.ts +124 -124
- package/src/server/services/LoopPatternSchema.ts +19 -1
- package/src/server/services/LoopPatternService.ts +143 -143
- package/src/server/services/LoopRunRepository.ts +99 -0
- package/src/server/services/LoopRunStateMachine.ts +100 -3
- package/src/server/services/LoopSchedulerService.ts +199 -199
- package/src/server/services/LoopTriggerService.ts +42 -0
- package/src/server/services/LoopWorkerService.ts +327 -27
- package/src/server/services/NativeSubAgentObserver.ts +186 -21
- package/src/server/services/PathLockService.ts +321 -321
- package/src/server/services/PluginAiRuntimeAdapter.ts +24 -7
- package/src/server/services/ToolLoopDetectionService.ts +213 -0
- package/src/server/services/VerificationSchema.ts +31 -31
- package/src/server/services/VerificationService.ts +81 -2
- package/src/server/services/harness-runtime-policy.ts +141 -0
- package/src/server/skill-hub/plugin.ts +41 -3
- package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +235 -235
- package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +61 -61
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +43 -2
- package/src/server/utils/ensure-indexes.ts +96 -96
- package/src/server/utils/logging.ts +62 -62
- package/src/server/utils/loop-pattern-context.ts +20 -20
- package/dist/client-v2/214.b063f33ba044a808.js +0 -10
- package/dist/client-v2/373.f5d5292e53c4e832.js +0 -10
- package/dist/client-v2/418.58fa350f5496efd3.js +0 -10
- package/dist/client-v2/53.9a10455323390f14.js +0 -10
- package/dist/client-v2/677.a991ce0250ff5c77.js +0 -10
- package/dist/client-v2/925.e5925bf21ed68e7a.js +0 -10
- package/src/client/AIEmployeeSelect.tsx +0 -47
- package/src/client/AIEmployeesContext.tsx +0 -102
- package/src/client/RulesTab.tsx +0 -2
- package/src/client/TracingTab.tsx +0 -436
- package/src/client/skill-hub/components/ExecutionProgress.tsx +0 -51
- package/src/client-v2/components/RulesTab.tsx +0 -2
- package/src/client-v2/pages/AgentRunsPage.tsx +0 -13
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var harness_runtime_policy_exports = {};
|
|
28
|
+
__export(harness_runtime_policy_exports, {
|
|
29
|
+
REDACTED_PLACEHOLDER: () => REDACTED_PLACEHOLDER,
|
|
30
|
+
harnessTimeoutMs: () => harnessTimeoutMs,
|
|
31
|
+
redactSecretsIn: () => redactSecretsIn,
|
|
32
|
+
resolveRunRoleHarness: () => resolveRunRoleHarness,
|
|
33
|
+
resolveTraceHarness: () => resolveTraceHarness,
|
|
34
|
+
spilledText: () => spilledText
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(harness_runtime_policy_exports);
|
|
37
|
+
var import_HarnessCompiler = require("./HarnessCompiler");
|
|
38
|
+
var import_HarnessProfileService = require("./HarnessProfileService");
|
|
39
|
+
var import_HarnessSchema = require("./HarnessSchema");
|
|
40
|
+
function read(record, key) {
|
|
41
|
+
const model = record;
|
|
42
|
+
return typeof (model == null ? void 0 : model.get) === "function" ? model.get(key) : model == null ? void 0 : model[key];
|
|
43
|
+
}
|
|
44
|
+
function asObject(value) {
|
|
45
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
46
|
+
}
|
|
47
|
+
function compiledFromSnapshot(snapshot) {
|
|
48
|
+
const effective = asObject(asObject(snapshot).effective);
|
|
49
|
+
if (!effective.tools) return null;
|
|
50
|
+
const { sources: _sources, ...settings } = effective;
|
|
51
|
+
return (0, import_HarnessCompiler.compileHarness)([{ source: "run-snapshot", settings: (0, import_HarnessSchema.parseHarnessSettings)(settings) }]);
|
|
52
|
+
}
|
|
53
|
+
function snapshotForEmployee(run, username) {
|
|
54
|
+
const bindings = asObject(run.roleBindingsSnapshot);
|
|
55
|
+
if (!username) return null;
|
|
56
|
+
if (bindings.leader === username) return run.leaderHarnessSnapshot;
|
|
57
|
+
if (bindings.verifier === username) return run.verifierHarnessSnapshot;
|
|
58
|
+
const makers = asObject(run.makerHarnessSnapshot);
|
|
59
|
+
return makers[username] ?? null;
|
|
60
|
+
}
|
|
61
|
+
async function resolveRunRoleHarness(database, runId, username) {
|
|
62
|
+
var _a;
|
|
63
|
+
if (!Number.isSafeInteger(runId) || runId <= 0 || !username) return null;
|
|
64
|
+
const run = await database.getRepository("agentLoopRuns").findOne({ filterByTk: runId });
|
|
65
|
+
if (!run) return null;
|
|
66
|
+
const snapshot = snapshotForEmployee(asObject(((_a = run.toJSON) == null ? void 0 : _a.call(run)) ?? run), username);
|
|
67
|
+
return compiledFromSnapshot(snapshot);
|
|
68
|
+
}
|
|
69
|
+
async function resolveTraceHarness(database, trace) {
|
|
70
|
+
const runHarness = await resolveRunRoleHarness(database, Number(trace.agentLoopRunId), trace.employeeUsername);
|
|
71
|
+
if (runHarness) return runHarness;
|
|
72
|
+
if (!trace.employeeUsername) return null;
|
|
73
|
+
const employee = await database.getRepository("aiEmployees").findOne({
|
|
74
|
+
filter: { username: trace.employeeUsername }
|
|
75
|
+
});
|
|
76
|
+
if (!employee) return null;
|
|
77
|
+
const settings = asObject(read(employee, "skillSettings"));
|
|
78
|
+
const tag = typeof settings.harnessTag === "string" && settings.harnessTag.trim() ? settings.harnessTag.trim() : "default";
|
|
79
|
+
const profiles = new import_HarnessProfileService.HarnessProfileService(database);
|
|
80
|
+
const version = await profiles.getPublishedByTag(tag) || (tag !== "default" ? await profiles.getPublishedByTag("default") : null);
|
|
81
|
+
if (!version) return null;
|
|
82
|
+
return (0, import_HarnessCompiler.compileHarness)([{ source: `profile:${tag}`, settings: version.settings }]);
|
|
83
|
+
}
|
|
84
|
+
function harnessTimeoutMs(harness, toolName) {
|
|
85
|
+
const timeouts = harness.tools.timeouts;
|
|
86
|
+
const direct = timeouts[toolName];
|
|
87
|
+
if (typeof direct === "number" && direct > 0) return direct;
|
|
88
|
+
const generic = timeouts["skill_hub_execute"];
|
|
89
|
+
return typeof generic === "number" && generic > 0 ? generic : null;
|
|
90
|
+
}
|
|
91
|
+
const SECRET_KEY_PATTERN = /(?:KEY|SECRET|TOKEN|PASSWORD|PASSWD|CREDENTIAL)/i;
|
|
92
|
+
const REDACTED_PLACEHOLDER = "[REDACTED]";
|
|
93
|
+
function redactSecretsIn(value) {
|
|
94
|
+
const scrub = (input, depth) => {
|
|
95
|
+
if (depth > 8 || input === null || input === void 0) return input;
|
|
96
|
+
if (Array.isArray(input)) return input.map((item) => scrub(item, depth + 1));
|
|
97
|
+
if (typeof input === "object") {
|
|
98
|
+
const source = input;
|
|
99
|
+
const output = {};
|
|
100
|
+
for (const [key, entry] of Object.entries(source)) {
|
|
101
|
+
output[key] = SECRET_KEY_PATTERN.test(key) ? REDACTED_PLACEHOLDER : scrub(entry, depth + 1);
|
|
102
|
+
}
|
|
103
|
+
return output;
|
|
104
|
+
}
|
|
105
|
+
return input;
|
|
106
|
+
};
|
|
107
|
+
return scrub(value, 0);
|
|
108
|
+
}
|
|
109
|
+
function sliceBytes(buffer, start, end) {
|
|
110
|
+
let from = Math.max(0, start);
|
|
111
|
+
while (from < end && (buffer[from] & 192) === 128) from += 1;
|
|
112
|
+
return buffer.subarray(from, Math.min(buffer.length, end));
|
|
113
|
+
}
|
|
114
|
+
function spilledText(text, maxInlineBytes, locator) {
|
|
115
|
+
const buffer = Buffer.from(text, "utf8");
|
|
116
|
+
if (buffer.byteLength <= maxInlineBytes) return null;
|
|
117
|
+
const headTarget = Math.floor(maxInlineBytes * 0.6);
|
|
118
|
+
const tailTarget = Math.floor(maxInlineBytes * 0.2);
|
|
119
|
+
let head = sliceBytes(buffer, 0, headTarget).toString("utf8");
|
|
120
|
+
let tail = sliceBytes(buffer, buffer.byteLength - tailTarget, buffer.byteLength).toString("utf8");
|
|
121
|
+
const notice = () => `
|
|
122
|
+
|
|
123
|
+
... (${buffer.byteLength - Buffer.byteLength(head, "utf8") - Buffer.byteLength(tail, "utf8")} bytes omitted. Full output stored at: ${locator}) ...`;
|
|
124
|
+
while (Buffer.byteLength(head + notice() + tail, "utf8") > maxInlineBytes && head.length + tail.length > 0) {
|
|
125
|
+
head = head.slice(0, Math.floor(head.length * 0.9));
|
|
126
|
+
const keepTail = Math.floor(tail.length * 0.9);
|
|
127
|
+
tail = keepTail > 0 ? tail.slice(-keepTail) : "";
|
|
128
|
+
}
|
|
129
|
+
return `${head}${notice()}${tail}`;
|
|
130
|
+
}
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
REDACTED_PLACEHOLDER,
|
|
134
|
+
harnessTimeoutMs,
|
|
135
|
+
redactSecretsIn,
|
|
136
|
+
resolveRunRoleHarness,
|
|
137
|
+
resolveTraceHarness,
|
|
138
|
+
spilledText
|
|
139
|
+
});
|
|
@@ -56,6 +56,7 @@ var import_git_import = require("./actions/git-import");
|
|
|
56
56
|
var import_git_import_request_method_policy = require("./middlewares/git-import-request-method-policy");
|
|
57
57
|
var import_json_fields = require("./utils/json-fields");
|
|
58
58
|
var import_ExecutionSpanService = require("../services/ExecutionSpanService");
|
|
59
|
+
var import_harness_runtime_policy = require("../services/harness-runtime-policy");
|
|
59
60
|
var import_ai_manager = require("../utils/ai-manager");
|
|
60
61
|
var import_SkillAccessService = require("../services/SkillAccessService");
|
|
61
62
|
var import_InputSchemaValidator = require("../services/InputSchemaValidator");
|
|
@@ -425,6 +426,35 @@ class SkillHubSubFeature {
|
|
|
425
426
|
this.skillTaskPolling = false;
|
|
426
427
|
}
|
|
427
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Resolve harness-derived enforcement overrides for one skill execution. The worker node owns
|
|
431
|
+
* the sandbox but not the harness, so the decision is made here (run snapshot for loop runs,
|
|
432
|
+
* employee harness-tag profile otherwise) and persisted on the execution row. A resolution
|
|
433
|
+
* failure must never block execution: the skill falls back to its own defaults.
|
|
434
|
+
*/
|
|
435
|
+
async resolveRuntimePolicy(traceContext, skill, aiEmployeeUsername) {
|
|
436
|
+
var _a, _b, _c;
|
|
437
|
+
try {
|
|
438
|
+
const harness = await (0, import_harness_runtime_policy.resolveTraceHarness)(this.db, {
|
|
439
|
+
agentLoopRunId: traceContext == null ? void 0 : traceContext.agentLoopRunId,
|
|
440
|
+
employeeUsername: (traceContext == null ? void 0 : traceContext.employeeUsername) || aiEmployeeUsername
|
|
441
|
+
});
|
|
442
|
+
if (!harness) return null;
|
|
443
|
+
const policy = {};
|
|
444
|
+
const timeoutMs = (0, import_harness_runtime_policy.harnessTimeoutMs)(harness, (0, import_skill_tool_name.getSkillToolName)(skill));
|
|
445
|
+
if (timeoutMs) {
|
|
446
|
+
const skillTimeoutSeconds = Number(skill.timeoutSeconds || ((_a = skill.get) == null ? void 0 : _a.call(skill, "timeoutSeconds")) || 60);
|
|
447
|
+
policy.timeoutSeconds = Math.min(skillTimeoutSeconds, Math.ceil(timeoutMs / 1e3));
|
|
448
|
+
}
|
|
449
|
+
if (harness.context.spill.maxInlineBytes) {
|
|
450
|
+
policy.spillMaxInlineBytes = harness.context.spill.maxInlineBytes;
|
|
451
|
+
}
|
|
452
|
+
return Object.keys(policy).length ? policy : null;
|
|
453
|
+
} catch (error) {
|
|
454
|
+
(_c = (_b = this.app.logger) == null ? void 0 : _b.warn) == null ? void 0 : _c.call(_b, "[skill-hub] Failed to resolve harness runtime policy.", { error });
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
428
458
|
/**
|
|
429
459
|
* Execute skill — called by both AI tool and REST test endpoint.
|
|
430
460
|
* Dispatches to sandbox workers via PubSub, waits for result via PubSub.
|
|
@@ -445,6 +475,7 @@ class SkillHubSubFeature {
|
|
|
445
475
|
}
|
|
446
476
|
}
|
|
447
477
|
const traceContext = (0, import_ExecutionSpanService.getOrchestratorTraceContext)(ctx);
|
|
478
|
+
const runtimePolicy = await this.resolveRuntimePolicy(traceContext, skill, aiEmployeeUsername);
|
|
448
479
|
const execution = await this.db.getRepository("skillExecutions").create({
|
|
449
480
|
values: {
|
|
450
481
|
skillId: skill.id,
|
|
@@ -459,7 +490,8 @@ class SkillHubSubFeature {
|
|
|
459
490
|
orchestratorToolCallId: traceContext == null ? void 0 : traceContext.toolCallId,
|
|
460
491
|
agentLoopRunId: traceContext == null ? void 0 : traceContext.agentLoopRunId,
|
|
461
492
|
agentLoopStepId: traceContext == null ? void 0 : traceContext.agentLoopStepId,
|
|
462
|
-
triggeredById: (_f = (_e = ctx == null ? void 0 : ctx.state) == null ? void 0 : _e.currentUser) == null ? void 0 : _f.id
|
|
493
|
+
triggeredById: (_f = (_e = ctx == null ? void 0 : ctx.state) == null ? void 0 : _e.currentUser) == null ? void 0 : _f.id,
|
|
494
|
+
runtimePolicy
|
|
463
495
|
}
|
|
464
496
|
});
|
|
465
497
|
const execId = String(execution.id);
|
|
@@ -495,10 +527,11 @@ class SkillHubSubFeature {
|
|
|
495
527
|
resolvePromise = resolve2;
|
|
496
528
|
rejectPromise = reject;
|
|
497
529
|
});
|
|
498
|
-
const
|
|
530
|
+
const effectiveTimeoutSeconds = (runtimePolicy == null ? void 0 : runtimePolicy.timeoutSeconds) || skill.timeoutSeconds || ((_g = skill.get) == null ? void 0 : _g.call(skill, "timeoutSeconds")) || 60;
|
|
531
|
+
const timeoutMs = (effectiveTimeoutSeconds + 15) * 1e3;
|
|
499
532
|
const timeout = setTimeout(() => {
|
|
500
533
|
clearInterval(poll);
|
|
501
|
-
rejectPromise(new Error(`Skill execution timeout after ${
|
|
534
|
+
rejectPromise(new Error(`Skill execution timeout after ${effectiveTimeoutSeconds}s`));
|
|
502
535
|
}, timeoutMs);
|
|
503
536
|
const poll = setInterval(async () => {
|
|
504
537
|
var _a2, _b2, _c2, _d2, _e2;
|
|
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(SkillExecutionTask_exports);
|
|
|
32
32
|
var import_fs = require("fs");
|
|
33
33
|
var import_path = require("path");
|
|
34
34
|
var import_CodeValidator = require("../../services/CodeValidator");
|
|
35
|
+
var import_harness_runtime_policy = require("../../services/harness-runtime-policy");
|
|
35
36
|
var import_crypto = require("crypto");
|
|
36
37
|
var import_skill_tool_name = require("../../utils/skill-tool-name");
|
|
37
38
|
var import_json_fields = require("../utils/json-fields");
|
|
@@ -155,6 +156,14 @@ class SkillExecutionTask {
|
|
|
155
156
|
throw new Error(`Plugin skill "${pluginSkillName}" not found. Is the parent plugin enabled?`);
|
|
156
157
|
}
|
|
157
158
|
}
|
|
159
|
+
const runtimePolicy = (0, import_json_fields.parseJsonLike)(
|
|
160
|
+
this.execution.get ? this.execution.get("runtimePolicy") : this.execution.runtimePolicy,
|
|
161
|
+
{}
|
|
162
|
+
);
|
|
163
|
+
if (typeof (runtimePolicy == null ? void 0 : runtimePolicy.timeoutSeconds) === "number" && runtimePolicy.timeoutSeconds > 0) {
|
|
164
|
+
timeoutSeconds = Math.min(Number(timeoutSeconds) || 60, runtimePolicy.timeoutSeconds);
|
|
165
|
+
}
|
|
166
|
+
const spillMaxInlineBytes = typeof (runtimePolicy == null ? void 0 : runtimePolicy.spillMaxInlineBytes) === "number" && runtimePolicy.spillMaxInlineBytes > 0 ? runtimePolicy.spillMaxInlineBytes : null;
|
|
158
167
|
if (!rawCodeTemplate) {
|
|
159
168
|
throw new Error(
|
|
160
169
|
`Skill "${skillName}" has no codeTemplate. Add a code file, inline codeTemplate, or bind it to an installed plugin skill.`
|
|
@@ -260,6 +269,26 @@ class SkillExecutionTask {
|
|
|
260
269
|
} else {
|
|
261
270
|
status = result.success ? "succeeded" : "failed";
|
|
262
271
|
}
|
|
272
|
+
if (spillMaxInlineBytes && typeof result.stdout === "string") {
|
|
273
|
+
const spillName = "stdout-full.txt";
|
|
274
|
+
const spillPath = (0, import_path.resolve)(this.fileManager.getOutputDir(execId), spillName);
|
|
275
|
+
const locator = `/api/skillHub:download?execId=${execId}&f=${Buffer.from(spillName).toString("base64url")}`;
|
|
276
|
+
const replaced = (0, import_harness_runtime_policy.spilledText)(result.stdout, spillMaxInlineBytes, locator);
|
|
277
|
+
if (replaced) {
|
|
278
|
+
try {
|
|
279
|
+
(0, import_fs.writeFileSync)(spillPath, result.stdout, "utf8");
|
|
280
|
+
result.stdout = replaced;
|
|
281
|
+
result.files = [
|
|
282
|
+
...result.files || [],
|
|
283
|
+
{ name: spillName, size: (0, import_fs.statSync)(spillPath).size, mimeType: "text/plain" }
|
|
284
|
+
];
|
|
285
|
+
} catch (spillError) {
|
|
286
|
+
this.app.logger.warn(`[skill-hub] Task ${execId}: stdout spill failed`, {
|
|
287
|
+
error: spillError
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
263
292
|
const completed = await this.updateIfOwned(execId, workerId, {
|
|
264
293
|
status,
|
|
265
294
|
stdout: result.stdout,
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "plugin-agent-orchestrator",
|
|
3
|
-
"displayName": "Agent Orchestrator",
|
|
4
|
-
"displayName.zh-CN": "代理协调器",
|
|
5
|
-
"displayName.vi-VN": "Điều phối Agent",
|
|
6
|
-
"description": "Native AI Employee sub-agent monitoring, policy, and memory context layer for NocoBase plugin-ai.",
|
|
7
|
-
"version": "1.1.
|
|
8
|
-
"license": "Apache-2.0",
|
|
9
|
-
"main": "dist/server/index.js",
|
|
10
|
-
"keywords": [
|
|
11
|
-
"AI",
|
|
12
|
-
"Agent",
|
|
13
|
-
"Orchestrator",
|
|
14
|
-
"Multi-Agent",
|
|
15
|
-
"Swarm"
|
|
16
|
-
],
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"src",
|
|
20
|
-
"client.js",
|
|
21
|
-
"server.js",
|
|
22
|
-
"client.d.ts",
|
|
23
|
-
"server.d.ts",
|
|
24
|
-
"client-v2.js",
|
|
25
|
-
"client-v2.d.ts"
|
|
26
|
-
],
|
|
27
|
-
"nocobase": {
|
|
28
|
-
"supportedVersions": [
|
|
29
|
-
"2.x"
|
|
30
|
-
],
|
|
31
|
-
"editionLevel": 0
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"adm-zip": "^0.5.10",
|
|
35
|
-
"ajv": "^6.12.6",
|
|
36
|
-
"zod": "^3.23.0"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"@nocobase/client": "2.x",
|
|
40
|
-
"@nocobase/server": "2.x",
|
|
41
|
-
"@nocobase/database": "2.x",
|
|
42
|
-
"@nocobase/ai": "2.x",
|
|
43
|
-
"@nocobase/plugin-ai": "2.x",
|
|
44
|
-
"@nocobase/client-v2": "2.x",
|
|
45
|
-
"@nocobase/flow-engine": "2.x",
|
|
46
|
-
"plugin-git-manager": "^1.2.24"
|
|
47
|
-
},
|
|
48
|
-
"peerDependenciesMeta": {
|
|
49
|
-
"plugin-git-manager": {
|
|
50
|
-
"optional": true
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "plugin-agent-orchestrator",
|
|
3
|
+
"displayName": "Agent Orchestrator",
|
|
4
|
+
"displayName.zh-CN": "代理协调器",
|
|
5
|
+
"displayName.vi-VN": "Điều phối Agent",
|
|
6
|
+
"description": "Native AI Employee sub-agent monitoring, policy, and memory context layer for NocoBase plugin-ai.",
|
|
7
|
+
"version": "1.1.5",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"main": "dist/server/index.js",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"AI",
|
|
12
|
+
"Agent",
|
|
13
|
+
"Orchestrator",
|
|
14
|
+
"Multi-Agent",
|
|
15
|
+
"Swarm"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src",
|
|
20
|
+
"client.js",
|
|
21
|
+
"server.js",
|
|
22
|
+
"client.d.ts",
|
|
23
|
+
"server.d.ts",
|
|
24
|
+
"client-v2.js",
|
|
25
|
+
"client-v2.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"nocobase": {
|
|
28
|
+
"supportedVersions": [
|
|
29
|
+
"2.x"
|
|
30
|
+
],
|
|
31
|
+
"editionLevel": 0
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"adm-zip": "^0.5.10",
|
|
35
|
+
"ajv": "^6.12.6",
|
|
36
|
+
"zod": "^3.23.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@nocobase/client": "2.x",
|
|
40
|
+
"@nocobase/server": "2.x",
|
|
41
|
+
"@nocobase/database": "2.x",
|
|
42
|
+
"@nocobase/ai": "2.x",
|
|
43
|
+
"@nocobase/plugin-ai": "2.x",
|
|
44
|
+
"@nocobase/client-v2": "2.x",
|
|
45
|
+
"@nocobase/flow-engine": "2.x",
|
|
46
|
+
"plugin-git-manager": "^1.2.24"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"plugin-git-manager": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Tabs } from 'antd';
|
|
3
3
|
import {
|
|
4
4
|
ApiOutlined,
|
|
5
|
+
AuditOutlined,
|
|
5
6
|
BarChartOutlined,
|
|
6
7
|
CheckCircleOutlined,
|
|
7
8
|
CodeOutlined,
|
|
@@ -19,6 +20,7 @@ import { RetrievalTraceTab } from '../client-v2/components/RetrievalTraceTab';
|
|
|
19
20
|
import { MemoryInspectorTab } from '../client-v2/components/MemoryInspectorTab';
|
|
20
21
|
import { AgentRunsTab } from './AgentRunsTab';
|
|
21
22
|
import { HarnessProfilesTab } from './HarnessProfilesTab';
|
|
23
|
+
import { ApprovalsTab } from './ApprovalsTab';
|
|
22
24
|
import { AIEmployeesProvider } from '../client-v2/components/AIEmployeesContext';
|
|
23
25
|
import { useT } from './skill-hub/locale';
|
|
24
26
|
import { SkillManager, ExecutionHistory, SkillMetrics, LoopSettings } from './skill-hub';
|
|
@@ -59,6 +61,15 @@ const OrchestratorSettings: React.FC = () => {
|
|
|
59
61
|
),
|
|
60
62
|
children: <HarnessProfilesTab />,
|
|
61
63
|
},
|
|
64
|
+
{
|
|
65
|
+
key: 'approvals',
|
|
66
|
+
label: (
|
|
67
|
+
<span>
|
|
68
|
+
<AuditOutlined /> {t('Approvals')}
|
|
69
|
+
</span>
|
|
70
|
+
),
|
|
71
|
+
children: <ApprovalsTab />,
|
|
72
|
+
},
|
|
62
73
|
{
|
|
63
74
|
key: 'agent-bindings',
|
|
64
75
|
label: (
|
|
@@ -138,7 +138,7 @@ export const GitSkillImport: React.FC<GitSkillImportProps> = ({ open, onClose })
|
|
|
138
138
|
}
|
|
139
139
|
}, [step, selectedRepoId, selectedRef, currentTreePath, loadFolders]);
|
|
140
140
|
|
|
141
|
-
// Load skills from selected folder (without prefix
|
|
141
|
+
// Load skills from selected folder (without prefix — prefix is applied only on sync)
|
|
142
142
|
const loadSkills = useCallback(async () => {
|
|
143
143
|
if (!selectedRepoId || selectedRootFolder === null) return;
|
|
144
144
|
setSkillsLoading(true);
|
|
@@ -263,7 +263,7 @@ export const GitSkillImport: React.FC<GitSkillImportProps> = ({ open, onClose })
|
|
|
263
263
|
},
|
|
264
264
|
];
|
|
265
265
|
|
|
266
|
-
// Result columns
|
|
266
|
+
// Result columns — show name with prefix applied
|
|
267
267
|
const resultColumns = [
|
|
268
268
|
{
|
|
269
269
|
title: t('Skill'),
|
|
@@ -506,7 +506,7 @@ export const GitSkillImport: React.FC<GitSkillImportProps> = ({ open, onClose })
|
|
|
506
506
|
{filteredSkills.length} / {skills.length} {t('skills found')}
|
|
507
507
|
{importPrefix && (
|
|
508
508
|
<span style={{ marginLeft: 8 }}>
|
|
509
|
-
|
|
509
|
+
• {t('Prefix')}: <Tag style={{ margin: 0 }}>{importPrefix}</Tag>{' '}
|
|
510
510
|
<Text type="secondary" style={{ fontSize: 11 }}>
|
|
511
511
|
({t('applied on sync')})
|
|
512
512
|
</Text>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
-
import { Card, Table,
|
|
2
|
+
import { Alert, Card, Table, Space, Row, Col, Statistic, Progress } from 'antd';
|
|
3
3
|
import { SyncOutlined, CheckCircleOutlined, CloseCircleOutlined, ClockCircleOutlined } from '@ant-design/icons';
|
|
4
4
|
import { useApp } from '@nocobase/client-v2';
|
|
5
5
|
import { useT } from '../locale';
|
|
6
6
|
|
|
7
|
-
const { Title, Text } = Typography;
|
|
8
|
-
|
|
9
7
|
export const SkillMetrics: React.FC = () => {
|
|
10
8
|
const api = useApp().apiClient;
|
|
11
9
|
const t = useT();
|
|
12
10
|
const [executions, setExecutions] = useState<any[]>([]);
|
|
13
11
|
const [loading, setLoading] = useState(false);
|
|
12
|
+
const [error, setError] = useState<string | null>(null);
|
|
14
13
|
|
|
15
14
|
const fetchExecutions = useCallback(async () => {
|
|
16
15
|
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
17
|
try {
|
|
18
18
|
// Fetch up to 1000 recent executions to calculate basic metrics
|
|
19
19
|
const { data } = await api.request({
|
|
@@ -26,12 +26,16 @@ export const SkillMetrics: React.FC = () => {
|
|
|
26
26
|
});
|
|
27
27
|
const rawData = data?.data?.data ?? data?.data ?? [];
|
|
28
28
|
setExecutions(Array.isArray(rawData) ? rawData : []);
|
|
29
|
-
} catch {
|
|
30
|
-
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const response = err as { response?: { data?: { errors?: { message?: string }[] } } };
|
|
31
|
+
setExecutions([]);
|
|
32
|
+
setError(
|
|
33
|
+
response?.response?.data?.errors?.[0]?.message || (err as Error)?.message || t('Failed to load metrics'),
|
|
34
|
+
);
|
|
31
35
|
} finally {
|
|
32
36
|
setLoading(false);
|
|
33
37
|
}
|
|
34
|
-
}, [api]);
|
|
38
|
+
}, [api, t]);
|
|
35
39
|
|
|
36
40
|
useEffect(() => {
|
|
37
41
|
fetchExecutions();
|
|
@@ -103,16 +107,17 @@ export const SkillMetrics: React.FC = () => {
|
|
|
103
107
|
|
|
104
108
|
return (
|
|
105
109
|
<Space direction="vertical" size="large" style={{ width: '100%', padding: '0 16px' }}>
|
|
110
|
+
{error && <Alert type="error" showIcon message={error} />}
|
|
106
111
|
<Row gutter={16}>
|
|
107
112
|
<Col span={6}>
|
|
108
113
|
<Card size="small">
|
|
109
|
-
<Statistic title=
|
|
114
|
+
<Statistic title={t('Total Executions (Recent)')} value={metrics.total} prefix={<SyncOutlined />} />
|
|
110
115
|
</Card>
|
|
111
116
|
</Col>
|
|
112
117
|
<Col span={6}>
|
|
113
118
|
<Card size="small">
|
|
114
119
|
<Statistic
|
|
115
|
-
title=
|
|
120
|
+
title={t('Succeeded')}
|
|
116
121
|
value={metrics.succeeded}
|
|
117
122
|
valueStyle={{ color: '#3f8600' }}
|
|
118
123
|
prefix={<CheckCircleOutlined />}
|
|
@@ -122,7 +127,7 @@ export const SkillMetrics: React.FC = () => {
|
|
|
122
127
|
<Col span={6}>
|
|
123
128
|
<Card size="small">
|
|
124
129
|
<Statistic
|
|
125
|
-
title=
|
|
130
|
+
title={t('Failed')}
|
|
126
131
|
value={metrics.failed}
|
|
127
132
|
valueStyle={{ color: '#cf1322' }}
|
|
128
133
|
prefix={<CloseCircleOutlined />}
|
|
@@ -132,7 +137,7 @@ export const SkillMetrics: React.FC = () => {
|
|
|
132
137
|
<Col span={6}>
|
|
133
138
|
<Card size="small">
|
|
134
139
|
<Statistic
|
|
135
|
-
title=
|
|
140
|
+
title={t('Timeout/Canceled')}
|
|
136
141
|
value={metrics.timeout + metrics.canceled}
|
|
137
142
|
valueStyle={{ color: '#faad14' }}
|
|
138
143
|
prefix={<ClockCircleOutlined />}
|
|
@@ -1,58 +1,6 @@
|
|
|
1
|
-
import { Plugin } from '@nocobase/client';
|
|
2
1
|
import { SkillManager } from './components/SkillManager';
|
|
3
2
|
import { ExecutionHistory } from './components/ExecutionHistory';
|
|
4
3
|
import { SkillMetrics } from './components/SkillMetrics';
|
|
5
4
|
import { LoopSettings } from './components/LoopSettings';
|
|
6
|
-
import { InteractionSchemasProvider } from './tools/InteractionSchemasProvider';
|
|
7
|
-
import { registerSkillLoopCards } from './tools/registerSkillLoopCards';
|
|
8
|
-
|
|
9
|
-
export class PluginSkillHubClient extends Plugin {
|
|
10
|
-
async load() {
|
|
11
|
-
(this as any).app.use(InteractionSchemasProvider);
|
|
12
|
-
|
|
13
|
-
(this as any).app.pluginSettingsManager.add('skill-hub', {
|
|
14
|
-
title: (this as any).t('Skill Hub'),
|
|
15
|
-
icon: 'CodeOutlined',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
(this as any).app.pluginSettingsManager.add('skill-hub.definitions', {
|
|
19
|
-
title: (this as any).t('Skill Definitions'),
|
|
20
|
-
Component: SkillManager,
|
|
21
|
-
aclSnippet: 'pm.skill-hub',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
(this as any).app.pluginSettingsManager.add('skill-hub.loop-settings', {
|
|
25
|
-
title: (this as any).t('Skill Review Settings'),
|
|
26
|
-
Component: LoopSettings,
|
|
27
|
-
aclSnippet: 'pm.skill-hub',
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
(this as any).app.pluginSettingsManager.add('skill-hub.executions', {
|
|
31
|
-
title: (this as any).t('Execution History'),
|
|
32
|
-
Component: ExecutionHistory,
|
|
33
|
-
aclSnippet: 'pm.skill-hub',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
(this as any).app.pluginSettingsManager.add('skill-hub.metrics', {
|
|
37
|
-
title: (this as any).t('Dashboard Metrics'),
|
|
38
|
-
Component: SkillMetrics,
|
|
39
|
-
aclSnippet: 'pm.skill-hub',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
(this as any).app.eventBus?.addEventListener?.('auth:tokenChanged', (event: Event) => {
|
|
43
|
-
const token = (event as CustomEvent<{ token?: string | null }>).detail?.token;
|
|
44
|
-
if (token) {
|
|
45
|
-
this.registerSkillUiCards();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
await this.registerSkillUiCards();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private async registerSkillUiCards() {
|
|
53
|
-
await registerSkillLoopCards((this as any).app);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
5
|
|
|
57
6
|
export { SkillManager, ExecutionHistory, SkillMetrics, LoopSettings };
|
|
58
|
-
export default PluginSkillHubClient;
|