plugin-agent-orchestrator 1.2.0 → 1.2.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/LICENSE +201 -0
- package/dist/client/{117.2e4cb0477da3db1f.js → 117.6c69b6a87751dd18.js} +1 -1
- package/dist/client/{253.93deb9e0192e76a5.js → 253.52f62e1bc0e9520a.js} +1 -1
- package/dist/client/{404.498d2d9516dd1dce.js → 404.86593f98c9768ed5.js} +1 -1
- package/dist/client/{627.fdd60bcc0f3a9cf6.js → 453.fa2d169576262213.js} +1 -1
- package/dist/client/{53.774ff07505d521fa.js → 53.567db3ae078650c6.js} +1 -1
- package/dist/client/{619.e342b0fa467d39ca.js → 619.01713281e5e951d3.js} +1 -1
- package/dist/client/652.69da1598312b3a3f.js +10 -0
- package/dist/client/773.648965568ff476f9.js +10 -0
- package/dist/client/{981.e0546ffc34afedcd.js → 981.37e7aeecdb1ef6fa.js} +1 -1
- package/dist/client/{993.5d04b510835ab0d2.js → 993.ac89f3852990918d.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-v2/{117.ccf43ae8631f7d74.js → 117.c982d79ff68738f5.js} +1 -1
- package/dist/client-v2/{214.cdf76752053a8990.js → 214.94c4257bf2838577.js} +1 -1
- package/dist/client-v2/{253.1198df22f5baf304.js → 253.8e19956d2a44dfb8.js} +1 -1
- package/dist/client-v2/{264.78887ff88f969467.js → 264.80e8e358c8c6c2e5.js} +1 -1
- package/dist/client-v2/{404.9ba964c28a151c81.js → 404.ab032b79c95dab6f.js} +1 -1
- package/dist/client-v2/{41.b28cf7a675a603d1.js → 41.cd5610fcf7446127.js} +1 -1
- package/dist/client-v2/{627.e16f4a0dd596c3e6.js → 453.42c6d70628d56cc2.js} +1 -1
- package/dist/client-v2/{53.282081f97e4308c6.js → 53.37c08089a648f89a.js} +1 -1
- package/dist/client-v2/{619.8c03913873785fb6.js → 619.6e9618550101e819.js} +1 -1
- package/dist/client-v2/652.eeba4e0c38367321.js +10 -0
- package/dist/client-v2/{70.9166ed70906d041f.js → 70.332698e53eb59677.js} +1 -1
- package/dist/client-v2/773.4de2ba5acb07318c.js +10 -0
- package/dist/client-v2/981.76060f466e6f7c11.js +10 -0
- package/dist/client-v2/{993.ca5b28f1e2b4c1ef.js → 993.f8cdb5172566ce75.js} +1 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +4 -1
- package/dist/locale/en-US.json +80 -1
- package/dist/locale/vi-VN.json +5 -1
- package/dist/locale/zh-CN.json +80 -1
- package/dist/node_modules/acorn/LICENSE +21 -0
- package/dist/node_modules/acorn/bin/acorn +4 -0
- package/dist/node_modules/acorn/dist/acorn.d.mts +857 -0
- package/dist/node_modules/acorn/dist/acorn.d.ts +857 -0
- package/dist/node_modules/acorn/dist/acorn.js +1 -0
- package/dist/node_modules/acorn/dist/bin.js +90 -0
- package/dist/node_modules/acorn/package.json +1 -0
- package/dist/node_modules/acorn-walk/LICENSE +21 -0
- package/dist/node_modules/acorn-walk/dist/walk.d.mts +177 -0
- package/dist/node_modules/acorn-walk/dist/walk.d.ts +177 -0
- package/dist/node_modules/acorn-walk/dist/walk.js +1 -0
- package/dist/node_modules/acorn-walk/node_modules/.bin/acorn +15 -0
- package/dist/node_modules/acorn-walk/node_modules/.bin/acorn.cmd +7 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/bin/acorn +4 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.d.mts +866 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.d.ts +866 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/dist/acorn.js +6174 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/dist/bin.js +90 -0
- package/dist/node_modules/acorn-walk/node_modules/acorn/package.json +50 -0
- package/dist/node_modules/acorn-walk/package.json +1 -0
- package/dist/node_modules/adm-zip/package.json +1 -1
- package/dist/node_modules/ajv/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/collections/agent-auto-approval-checkpoints.js +47 -0
- package/dist/server/collections/agent-execution-spans.js +3 -3
- package/dist/server/collections/agent-hierarchy-invocations.js +59 -0
- package/dist/server/collections/agent-routing-graph-locks.js +40 -0
- package/dist/server/collections/agent-session-auto-approvals.js +45 -0
- package/dist/server/collections/orchestrator-config.js +17 -0
- package/dist/server/migrations/20261119000000-widen-native-employee-identifiers.js +59 -0
- package/dist/server/plugin.js +55 -0
- package/dist/server/resources/agent-auto-approval.js +80 -0
- package/dist/server/resources/hierarchical-routing.js +60 -0
- package/dist/server/services/AutoApprovalCheckpoint.js +133 -0
- package/dist/server/services/CodeValidator.js +8 -4
- package/dist/server/services/GovernanceAdmission.js +60 -0
- package/dist/server/services/HarnessCompiler.js +3 -0
- package/dist/server/services/HarnessSchema.js +13 -1
- package/dist/server/services/HierarchicalAgentRuntime.js +925 -0
- package/dist/server/services/HierarchyEnrollmentGuard.js +216 -0
- package/dist/server/services/HierarchyInvocationJournal.js +157 -0
- package/dist/server/services/HierarchyRequestCancellation.js +150 -0
- package/dist/server/services/LoopRunRepository.js +1 -1
- package/dist/server/services/LoopRunStateMachine.js +2 -2
- package/dist/server/services/LoopWorkerService.js +7 -7
- package/dist/server/services/PluginAiRuntimeAdapter.js +107 -9
- package/dist/server/services/RoutingBindingRepository.js +156 -0
- package/dist/server/services/RoutingBindingValidation.js +161 -0
- package/dist/server/services/SandboxRunner.js +19 -0
- package/dist/server/services/SessionAutoApproval.js +173 -0
- package/dist/server/services/VerificationService.js +2 -2
- package/dist/server/skill-hub/plugin.js +17 -0
- package/dist/server/skill-hub/services/RegistrySkillInstallationService.js +2 -2
- package/dist/server/skill-hub/services/registry-node-package.js +191 -0
- package/dist/server/skill-hub/tasks/SkillExecutionTask.js +21 -6
- package/dist/server/tools/skill-execute.js +1 -0
- package/dist/server/utils/ensure-indexes.js +1 -0
- package/package.json +5 -2
- package/src/client/SkillPages.tsx +1 -8
- package/src/client/__tests__/embedded-settings.test.tsx +1 -8
- package/src/client/plugin.tsx +3 -8
- package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +21 -6
- package/src/client/skill-hub/tools/SkillHubCard.tsx +22 -16
- package/src/client/skill-hub/tools/__tests__/skill-hub-card.test.tsx +255 -0
- package/src/client/skill-hub/tools/registerSkillLoopCards.ts +12 -3
- package/src/client-v2/__tests__/embedded-settings.test.tsx +20 -11
- package/src/client-v2/__tests__/hierarchical-routing-settings.test.tsx +350 -0
- package/src/client-v2/auto-approval/AutoApprovalBridge.tsx +513 -0
- package/src/client-v2/auto-approval/AutoApprovalProvider.tsx +399 -0
- package/src/client-v2/auto-approval/__tests__/session-auto-approval.test.tsx +1676 -0
- package/src/client-v2/components/AgentBindingsTab.tsx +275 -3
- package/src/client-v2/components/AgentRunsTab.tsx +1 -8
- package/src/client-v2/components/EmployeeGovernanceTab.tsx +1 -8
- package/src/client-v2/components/HarnessProfilesTab.tsx +4 -8
- package/src/client-v2/components/HarnessSettingsForm.tsx +221 -0
- package/src/client-v2/components/UsageGovernanceTab.tsx +1 -8
- package/src/client-v2/pages/AgentBindingsPage.tsx +1 -8
- package/src/client-v2/pages/ApprovalsPage.tsx +1 -8
- package/src/client-v2/pages/EmployeeGovernancePage.tsx +1 -8
- package/src/client-v2/pages/ExecutionHistoryPage.tsx +1 -8
- package/src/client-v2/pages/HarnessProfilesPage.tsx +1 -8
- package/src/client-v2/pages/KnowledgeAccessPage.tsx +1 -8
- package/src/client-v2/pages/LoopSettingsPage.tsx +1 -8
- package/src/client-v2/pages/MemoryInspectorPage.tsx +1 -8
- package/src/client-v2/pages/RetrievalTracePage.tsx +1 -8
- package/src/client-v2/pages/RulesPage.tsx +1 -8
- package/src/client-v2/pages/SkillDefinitionsPage.tsx +1 -8
- package/src/client-v2/pages/SkillMetricsPage.tsx +1 -8
- package/src/client-v2/pages/TracingPage.tsx +1 -8
- package/src/client-v2/pages/UsageGovernancePage.tsx +1 -8
- package/src/client-v2/plugin.tsx +3 -8
- package/src/client-v2/skill-hub/tools/__tests__/interactions.test.ts +17 -1
- package/src/client-v2/skill-hub/tools/interactions.ts +12 -3
- package/src/locale/en-US.json +80 -1
- package/src/locale/vi-VN.json +5 -1
- package/src/locale/zh-CN.json +80 -1
- package/src/server/__tests__/agent-governance.integration.test.ts +1 -8
- package/src/server/__tests__/agent-monitor-acl.integration.test.ts +1 -8
- package/src/server/__tests__/agent-usage-report.integration.test.ts +1 -8
- package/src/server/__tests__/auto-approval-checkpoint.integration.test.ts +295 -0
- package/src/server/__tests__/harness-capabilities.test.ts +1 -8
- package/src/server/__tests__/harness-compiler.test.ts +64 -0
- package/src/server/__tests__/harness-tool-plan.test.ts +1 -8
- package/src/server/__tests__/hierarchical-routing.integration.test.ts +2318 -0
- package/src/server/__tests__/hierarchy-invocation-journal.integration.test.ts +119 -0
- package/src/server/__tests__/loop-approval-decision.test.ts +59 -12
- package/src/server/__tests__/loop-budget-service.test.ts +1 -8
- package/src/server/__tests__/loop-run-repository.test.ts +1 -8
- package/src/server/__tests__/loop-trigger-service.test.ts +1 -8
- package/src/server/__tests__/loop-worker-claim.test.ts +46 -9
- package/src/server/__tests__/loop-worker-execution.test.ts +1 -8
- package/src/server/__tests__/native-agent-monitor-sync.test.ts +1 -8
- package/src/server/__tests__/native-hierarchy-probe.integration.test.ts +527 -0
- package/src/server/__tests__/native-sub-agent-observer.test.ts +1 -8
- package/src/server/__tests__/native-usage-attribution.integration.test.ts +1 -8
- package/src/server/__tests__/plugin-ai-runtime-adapter.test.ts +403 -0
- package/src/server/__tests__/registry-node-package.test.ts +299 -0
- package/src/server/__tests__/routing-binding-graph.integration.test.ts +217 -0
- package/src/server/__tests__/routing-binding-validation.test.ts +256 -0
- package/src/server/__tests__/session-auto-approval.integration.test.ts +329 -0
- package/src/server/__tests__/skill-execute.test.ts +11 -0
- package/src/server/__tests__/skill-review-guard.test.ts +171 -0
- package/src/server/__tests__/token-tracker.test.ts +1 -8
- package/src/server/__tests__/tracing-retention-policy.test.ts +1 -8
- package/src/server/__tests__/usage-ledger.integration.test.ts +1 -8
- package/src/server/collections/agent-auto-approval-checkpoints.ts +18 -0
- package/src/server/collections/agent-execution-spans.ts +4 -11
- package/src/server/collections/agent-governance-audit-events.ts +1 -8
- package/src/server/collections/agent-governance-policies.ts +1 -8
- package/src/server/collections/agent-governance-policy-versions.ts +1 -8
- package/src/server/collections/agent-governance-prompt-bindings.ts +1 -8
- package/src/server/collections/agent-hierarchy-invocations.ts +30 -0
- package/src/server/collections/agent-loop-runs.ts +1 -8
- package/src/server/collections/agent-routing-graph-locks.ts +11 -0
- package/src/server/collections/agent-session-auto-approvals.ts +16 -0
- package/src/server/collections/orchestrator-config.ts +26 -0
- package/src/server/migrations/20261110000000-add-usage-pricing-snapshots.ts +1 -8
- package/src/server/migrations/20261110010000-add-usage-department-attribution.ts +1 -8
- package/src/server/migrations/20261119000000-widen-native-employee-identifiers.ts +37 -0
- package/src/server/plugin.ts +58 -8
- package/src/server/resources/agent-auto-approval.ts +51 -0
- package/src/server/resources/agent-governance.ts +1 -8
- package/src/server/resources/agent-harness-profile.ts +1 -8
- package/src/server/resources/agent-monitor.ts +1 -8
- package/src/server/resources/agent-usage.ts +1 -8
- package/src/server/resources/hierarchical-routing.ts +39 -0
- package/src/server/resources/native-monitor-format.ts +1 -8
- package/src/server/resources/tracing.ts +1 -8
- package/src/server/services/AgentGovernanceService.ts +1 -8
- package/src/server/services/AutoApprovalCheckpoint.ts +140 -0
- package/src/server/services/CodeValidator.ts +23 -4
- package/src/server/services/DepartmentAttribution.ts +1 -8
- package/src/server/services/ExecutionSpanService.ts +1 -8
- package/src/server/services/GovernanceAdmission.ts +83 -8
- package/src/server/services/HarnessCapabilities.ts +1 -8
- package/src/server/services/HarnessCompiler.ts +12 -0
- package/src/server/services/HarnessSchema.ts +30 -0
- package/src/server/services/HierarchicalAgentRuntime.ts +1052 -0
- package/src/server/services/HierarchyEnrollmentGuard.ts +211 -0
- package/src/server/services/HierarchyInvocationJournal.ts +172 -0
- package/src/server/services/HierarchyRequestCancellation.ts +132 -0
- package/src/server/services/LoopBudgetService.ts +1 -8
- package/src/server/services/LoopRunRepository.ts +2 -9
- package/src/server/services/LoopRunStateMachine.ts +3 -10
- package/src/server/services/LoopTriggerService.ts +1 -8
- package/src/server/services/LoopWorkerService.ts +8 -19
- package/src/server/services/ManagedPromptProtection.ts +1 -8
- package/src/server/services/NativeAgentMonitorSyncService.ts +1 -8
- package/src/server/services/NativeSubAgentObserver.ts +1 -8
- package/src/server/services/NativeUsageAttribution.ts +1 -8
- package/src/server/services/PluginAiRuntimeAdapter.ts +140 -9
- package/src/server/services/RoutingBindingRepository.ts +146 -0
- package/src/server/services/RoutingBindingValidation.ts +161 -0
- package/src/server/services/SandboxRunner.ts +35 -1
- package/src/server/services/SessionAutoApproval.ts +167 -0
- package/src/server/services/TokenTracker.ts +1 -8
- package/src/server/services/TracingRetentionPolicy.ts +1 -8
- package/src/server/services/VerificationService.ts +3 -10
- package/src/server/skill-hub/plugin.ts +40 -0
- package/src/server/skill-hub/services/RegistrySkillInstallationService.ts +11 -1
- package/src/server/skill-hub/services/registry-node-package.ts +191 -0
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +34 -5
- package/src/server/tools/skill-execute.ts +10 -0
- package/src/server/utils/ensure-indexes.ts +2 -8
- package/dist/client/418.6f01da17774a5a25.js +0 -10
- package/dist/client/652.477e21bfff67bc1c.js +0 -10
- package/dist/client-v2/418.55b6b28cda8bb5f3.js +0 -10
- package/dist/client-v2/652.1a48364774d5383a.js +0 -10
- package/dist/client-v2/981.a81521f0296c7db8.js +0 -10
|
@@ -0,0 +1,173 @@
|
|
|
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 SessionAutoApproval_exports = {};
|
|
28
|
+
__export(SessionAutoApproval_exports, {
|
|
29
|
+
autoApprovalCall: () => autoApprovalCall,
|
|
30
|
+
guardAutoApprovalDecision: () => guardAutoApprovalDecision,
|
|
31
|
+
isAutoApprovalEligible: () => isAutoApprovalEligible,
|
|
32
|
+
sessionAutoApprovalEnabled: () => sessionAutoApprovalEnabled,
|
|
33
|
+
skillRequiresUserInput: () => skillRequiresUserInput
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(SessionAutoApproval_exports);
|
|
36
|
+
var import_ai_manager = require("../utils/ai-manager");
|
|
37
|
+
var import_record_utils = require("../utils/record-utils");
|
|
38
|
+
var import_skill_tool_name = require("../utils/skill-tool-name");
|
|
39
|
+
var import_json_fields = require("../skill-hub/utils/json-fields");
|
|
40
|
+
var import_AutoApprovalCheckpoint = require("./AutoApprovalCheckpoint");
|
|
41
|
+
const interactiveTools = /* @__PURE__ */ new Set(["suggestions", "aiEmployeeWorkflowTaskOutput"]);
|
|
42
|
+
function autoApprovalCall(values) {
|
|
43
|
+
const { sessionId, messageId, toolCallId } = values;
|
|
44
|
+
if (typeof sessionId !== "string" || !sessionId.trim() || sessionId.length > 100) return null;
|
|
45
|
+
if (!(typeof messageId === "string" && messageId.trim() || typeof messageId === "number" && Number.isSafeInteger(messageId) && messageId > 0))
|
|
46
|
+
return null;
|
|
47
|
+
if (typeof toolCallId !== "string" || !toolCallId.trim()) return null;
|
|
48
|
+
return { sessionId, messageId: String(messageId), toolCallId };
|
|
49
|
+
}
|
|
50
|
+
async function sessionAutoApprovalEnabled(ctx, sessionId) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const ownerId = (_b = (_a = ctx.auth) == null ? void 0 : _a.user) == null ? void 0 : _b.id;
|
|
53
|
+
if (!ownerId || !sessionId) return false;
|
|
54
|
+
const setting = await ctx.db.getRepository("agentSessionAutoApprovals").findOne({
|
|
55
|
+
filter: { ownerId, sessionId }
|
|
56
|
+
});
|
|
57
|
+
return (0, import_record_utils.read)(setting, "enabled") === true;
|
|
58
|
+
}
|
|
59
|
+
async function skillRequiresUserInput(ctx, name, args) {
|
|
60
|
+
const repository = ctx.db.getRepository("skillDefinitions");
|
|
61
|
+
let skill;
|
|
62
|
+
if (name === "skill_hub_execute") {
|
|
63
|
+
const input = (0, import_record_utils.asRecord)(args);
|
|
64
|
+
if (input.action === "list" || input.action === "describe") return false;
|
|
65
|
+
if (input.action !== "execute" || typeof input.skillName !== "string" || !input.skillName) return true;
|
|
66
|
+
skill = await repository.findOne({ filter: { name: input.skillName, enabled: true } });
|
|
67
|
+
if (!skill) return true;
|
|
68
|
+
} else {
|
|
69
|
+
skill = await repository.findOne({ filter: { toolName: name, enabled: true } });
|
|
70
|
+
if (!skill && name.startsWith("skill_hub_")) {
|
|
71
|
+
const legacy = await repository.find({ filter: { enabled: true } });
|
|
72
|
+
skill = legacy.find((item) => {
|
|
73
|
+
try {
|
|
74
|
+
return (0, import_skill_tool_name.getSkillToolName)(item) === name;
|
|
75
|
+
} catch {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!skill) return false;
|
|
81
|
+
}
|
|
82
|
+
const skillId = (0, import_record_utils.read)(skill, "id");
|
|
83
|
+
if (typeof skillId !== "number" && typeof skillId !== "string") return true;
|
|
84
|
+
const loop = await ctx.db.getRepository("skillLoopConfigs").findOne({
|
|
85
|
+
filter: { enabled: true, skillId },
|
|
86
|
+
sort: ["-updatedAt"]
|
|
87
|
+
});
|
|
88
|
+
const loopSchema = (0, import_json_fields.parseJsonText)((0, import_record_utils.read)(loop, "schema"), null);
|
|
89
|
+
if (loopSchema && typeof loopSchema === "object" || (0, import_record_utils.read)(loop, "prompt")) return true;
|
|
90
|
+
return Boolean((0, import_json_fields.parseJsonText)((0, import_record_utils.read)(skill, "interactionSchema"), null));
|
|
91
|
+
}
|
|
92
|
+
async function isAutoApprovalEligible(ctx, call) {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
const ownerId = (_b = (_a = ctx.auth) == null ? void 0 : _a.user) == null ? void 0 : _b.id;
|
|
95
|
+
if (!ownerId || !await sessionAutoApprovalEnabled(ctx, call.sessionId)) return false;
|
|
96
|
+
const conversation = await ctx.db.getRepository("aiConversations").findOne({
|
|
97
|
+
filter: { sessionId: call.sessionId, userId: ownerId }
|
|
98
|
+
});
|
|
99
|
+
if (!conversation || (0, import_record_utils.read)(conversation, "from") === "sub-agent") return false;
|
|
100
|
+
const username = (0, import_record_utils.read)(conversation, "aiEmployeeUsername");
|
|
101
|
+
if (typeof username !== "string" || !username) return false;
|
|
102
|
+
const requestedRoles = ctx.state.currentRoles;
|
|
103
|
+
if (!Array.isArray(requestedRoles)) return false;
|
|
104
|
+
const memberships = await ctx.db.getRepository("rolesUsers").find({ filter: { userId: ownerId } });
|
|
105
|
+
const memberRoles = new Set(memberships.map((row) => (0, import_record_utils.read)(row, "roleName")));
|
|
106
|
+
const roles = requestedRoles.filter(
|
|
107
|
+
(role) => typeof role === "string" && memberRoles.has(role)
|
|
108
|
+
);
|
|
109
|
+
if (!roles.length) return false;
|
|
110
|
+
if (typeof ctx.state.currentRole === "string" && ctx.state.currentRole !== "__union__" && !roles.includes(ctx.state.currentRole))
|
|
111
|
+
return false;
|
|
112
|
+
const filter = { username };
|
|
113
|
+
if (!roles.includes("root")) filter["roles.name"] = roles;
|
|
114
|
+
const employee = await ctx.db.getRepository("aiEmployees").findOne({ filter });
|
|
115
|
+
if (!employee || (0, import_record_utils.read)(employee, "enabled") === false) return false;
|
|
116
|
+
const message = await ctx.db.getRepository("aiMessages").findOne({
|
|
117
|
+
filter: { sessionId: call.sessionId, messageId: call.messageId, role: username }
|
|
118
|
+
});
|
|
119
|
+
const calls = (0, import_record_utils.read)(message, "toolCalls");
|
|
120
|
+
const selected = Array.isArray(calls) ? calls.map(import_record_utils.asRecord).find((item) => item.id === call.toolCallId) : void 0;
|
|
121
|
+
const name = selected == null ? void 0 : selected.name;
|
|
122
|
+
if (typeof name !== "string" || !name || interactiveTools.has(name)) return false;
|
|
123
|
+
if (await skillRequiresUserInput(ctx, name, selected.args)) return false;
|
|
124
|
+
const tool = await ctx.db.getRepository("aiToolMessages").findOne({
|
|
125
|
+
filter: { ...call, toolName: name, invokeStatus: "interrupted" }
|
|
126
|
+
});
|
|
127
|
+
if (!tool || (0, import_record_utils.read)(tool, "auto") !== false || (0, import_record_utils.read)(tool, "status") === "error") return false;
|
|
128
|
+
const interrupt = (0, import_record_utils.asRecord)((0, import_record_utils.read)(tool, "interruptAction"));
|
|
129
|
+
const interruptCall = (0, import_record_utils.asRecord)(interrupt.toolCall);
|
|
130
|
+
const interruptedConversation = (0, import_record_utils.asRecord)(interrupt.currentConversation);
|
|
131
|
+
const metadata = (0, import_record_utils.asRecord)((0, import_record_utils.read)(message, "metadata"));
|
|
132
|
+
if (!Array.isArray(interrupt.allowedDecisions) || !interrupt.allowedDecisions.includes("approve") || interruptCall.id !== call.toolCallId || interruptCall.name !== name || interruptedConversation.sessionId !== call.sessionId || interruptedConversation.from !== "main-agent" || interruptedConversation.username !== username || typeof metadata.interruptId !== "string" || !metadata.interruptId)
|
|
133
|
+
return false;
|
|
134
|
+
const entry = await (0, import_ai_manager.getAIToolsManager)(ctx.app).getTools(name, { ctx, sessionId: call.sessionId });
|
|
135
|
+
if (!entry || typeof entry.invoke !== "function") return false;
|
|
136
|
+
if (name === "executeFrontendTool") {
|
|
137
|
+
const toolId = (0, import_record_utils.asRecord)(selected.args).toolId;
|
|
138
|
+
const options = (0, import_record_utils.asRecord)((0, import_record_utils.read)(conversation, "options"));
|
|
139
|
+
const tools = options.frontendTools;
|
|
140
|
+
if (typeof toolId !== "string" || !Array.isArray(tools)) return false;
|
|
141
|
+
return tools.map(import_record_utils.asRecord).some((tool2) => tool2.id === toolId && tool2.id === `${tool2.blockUid}:${tool2.name}` && tool2.permission === "ASK");
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
async function guardAutoApprovalDecision(ctx, next) {
|
|
146
|
+
var _a, _b;
|
|
147
|
+
if (((_a = ctx.action) == null ? void 0 : _a.resourceName) !== "aiConversations" || ctx.action.actionName !== "updateUserDecision") return next();
|
|
148
|
+
const values = (0, import_record_utils.asRecord)((_b = ctx.action.params) == null ? void 0 : _b.values);
|
|
149
|
+
const automatic = values.agentAutoApproval === true;
|
|
150
|
+
const decision = (0, import_record_utils.asRecord)(values.userDecision);
|
|
151
|
+
const call = autoApprovalCall(values);
|
|
152
|
+
if (automatic && (!call || decision.type !== "approve" || !await isAutoApprovalEligible(ctx, call))) {
|
|
153
|
+
ctx.body = { updated: 0, toolCalls: [] };
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (!call) return next();
|
|
157
|
+
const checkpoint = await (0, import_AutoApprovalCheckpoint.autoApprovalCheckpoint)(ctx, call);
|
|
158
|
+
if (automatic && checkpoint === void 0) {
|
|
159
|
+
ctx.body = { updated: 0, toolCalls: [] };
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (automatic && checkpoint) await (0, import_AutoApprovalCheckpoint.enrollAutoApprovalCheckpoint)(ctx, checkpoint);
|
|
163
|
+
await next();
|
|
164
|
+
if (checkpoint) await (0, import_AutoApprovalCheckpoint.coordinateAutoApprovalDecision)(ctx, checkpoint, call);
|
|
165
|
+
}
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
autoApprovalCall,
|
|
169
|
+
guardAutoApprovalDecision,
|
|
170
|
+
isAutoApprovalEligible,
|
|
171
|
+
sessionAutoApprovalEnabled,
|
|
172
|
+
skillRequiresUserInput
|
|
173
|
+
});
|
|
@@ -118,7 +118,7 @@ class VerificationService {
|
|
|
118
118
|
eventType: "run_verified",
|
|
119
119
|
title: `Verifier returned ${verdict.verdict}`,
|
|
120
120
|
content: verdict.summary,
|
|
121
|
-
correlationKey: `verified:${input.
|
|
121
|
+
correlationKey: `verified:${input.leaseToken}`,
|
|
122
122
|
values: {
|
|
123
123
|
verifierVerdict: verdict.verdict,
|
|
124
124
|
verifierEvidence: verdict,
|
|
@@ -159,7 +159,7 @@ class VerificationService {
|
|
|
159
159
|
eventType: finding.level === "block" ? "run_blocked" : "run_escalated",
|
|
160
160
|
title: finding.level === "block" ? "Run blocked by tool loop detection" : "Run escalated by tool loop detection",
|
|
161
161
|
content: reason,
|
|
162
|
-
correlationKey: `tool-loop-${finding.level}:${input.
|
|
162
|
+
correlationKey: `tool-loop-${finding.level}:${input.leaseToken}`,
|
|
163
163
|
values: finding.level === "block" ? { blockedReason: reason } : { escalationReason: reason }
|
|
164
164
|
});
|
|
165
165
|
return "halt";
|
|
@@ -791,6 +791,22 @@ class SkillHubSubFeature {
|
|
|
791
791
|
}
|
|
792
792
|
return configsBySkillId;
|
|
793
793
|
}
|
|
794
|
+
async assertSkillReviewApproved(skill, runtime, toolName, ctx) {
|
|
795
|
+
var _a, _b;
|
|
796
|
+
const loopConfig = await this.db.getRepository("skillLoopConfigs").findOne({
|
|
797
|
+
filter: { enabled: true, skillId: this.getSkillRecordId(skill) },
|
|
798
|
+
sort: ["-updatedAt"]
|
|
799
|
+
});
|
|
800
|
+
const interactionSchema = this.resolveLoopInteractionSchema(loopConfig) || (0, import_json_fields.parseJsonText)((0, import_skill_tool_name.readRecordValue)(skill, "interactionSchema"), null);
|
|
801
|
+
if (!interactionSchema) return;
|
|
802
|
+
const toolCallId = (_a = normalizeToolRuntime(runtime)) == null ? void 0 : _a.toolCallId;
|
|
803
|
+
const call = toolCallId ? await this.db.getRepository("aiToolMessages").findOne({ filter: { toolCallId, toolName } }) : null;
|
|
804
|
+
const decision = (0, import_skill_tool_name.readRecordValue)((0, import_skill_tool_name.readRecordValue)(call, "userDecision"), "type");
|
|
805
|
+
if ((0, import_skill_tool_name.readRecordValue)(call, "auto") !== false || (0, import_skill_tool_name.readRecordValue)(call, "invokeStatus") !== "pending" || decision !== "approve" && decision !== "edit") {
|
|
806
|
+
const message = "Human review is required for this skill. Disable Auto call and approve the tool call before execution.";
|
|
807
|
+
throw new Error(((_b = ctx == null ? void 0 : ctx.t) == null ? void 0 : _b.call(ctx, message, { ns: "plugin-agent-orchestrator" })) || message);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
794
810
|
registerAITools() {
|
|
795
811
|
try {
|
|
796
812
|
const toolsManager = (0, import_ai_manager.tryGetAIToolsManager)(this.app);
|
|
@@ -846,6 +862,7 @@ IMPORTANT: This skill is bound to a Skill Hub human-in-the-loop review template.
|
|
|
846
862
|
if (!latestSkill) {
|
|
847
863
|
return { status: "error", content: `Skill "${skill.get("name")}" is no longer available` };
|
|
848
864
|
}
|
|
865
|
+
await this.assertSkillReviewApproved(latestSkill, runtime, (0, import_skill_tool_name.getSkillToolName)(skill), toolCtx);
|
|
849
866
|
const result = await this.executeSkill(latestSkill, args, toolCtx);
|
|
850
867
|
return {
|
|
851
868
|
status: result.status === "succeeded" ? "success" : "error",
|
|
@@ -31,6 +31,7 @@ __export(RegistrySkillInstallationService_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(RegistrySkillInstallationService_exports);
|
|
32
32
|
var import_crypto = require("crypto");
|
|
33
33
|
var import_skill_tool_name = require("../../utils/skill-tool-name");
|
|
34
|
+
var import_registry_node_package = require("./registry-node-package");
|
|
34
35
|
function read(model, attribute, fallback = "") {
|
|
35
36
|
const value = model.get(attribute);
|
|
36
37
|
return typeof value === "string" ? value : value === null || value === void 0 ? fallback : String(value);
|
|
@@ -58,8 +59,7 @@ function executionWrapper(runtime, entrypoint) {
|
|
|
58
59
|
""
|
|
59
60
|
].join("\n");
|
|
60
61
|
}
|
|
61
|
-
return
|
|
62
|
-
`;
|
|
62
|
+
return (0, import_registry_node_package.registryNodeWrapper)(entrypoint);
|
|
63
63
|
}
|
|
64
64
|
class RegistrySkillInstallationService {
|
|
65
65
|
constructor(database, getSkillRepository) {
|
|
@@ -0,0 +1,191 @@
|
|
|
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 registry_node_package_exports = {};
|
|
28
|
+
__export(registry_node_package_exports, {
|
|
29
|
+
registryNodeEntrypoint: () => registryNodeEntrypoint,
|
|
30
|
+
registryNodeWrapper: () => registryNodeWrapper,
|
|
31
|
+
validateRegistryNodePackage: () => validateRegistryNodePackage
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(registry_node_package_exports);
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var import_module = require("module");
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_vm = require("vm");
|
|
38
|
+
var import_acorn = require("acorn");
|
|
39
|
+
var import_acorn_walk = require("acorn-walk");
|
|
40
|
+
var import_CodeValidator = require("../../services/CodeValidator");
|
|
41
|
+
function registryNodeWrapper(entrypoint) {
|
|
42
|
+
return `require(${JSON.stringify(`./skill/${entrypoint}`)});
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
function registryNodeEntrypoint(template, translate) {
|
|
46
|
+
const legacy = template.match(
|
|
47
|
+
/^require\(require\('path'\)\.join\(process\.env\.SKILL_DIR, ("(?:[^"\\]|\\.)*")\)\);\s*$/
|
|
48
|
+
);
|
|
49
|
+
const current = template.match(/^require\(("(?:[^"\\]|\\.)*")\);\s*$/);
|
|
50
|
+
if (!legacy && !current) return null;
|
|
51
|
+
let path;
|
|
52
|
+
try {
|
|
53
|
+
path = JSON.parse((legacy || current)[1]);
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error(translate("Registry Node package requires must stay inside the package."));
|
|
56
|
+
}
|
|
57
|
+
if (current && !path.startsWith("./skill/")) return null;
|
|
58
|
+
const entrypoint = current ? path.slice("./skill/".length) : path;
|
|
59
|
+
if (!entrypoint || /[\\:\0]/.test(entrypoint) || entrypoint.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
60
|
+
throw new Error(translate("Registry Node package requires must stay inside the package."));
|
|
61
|
+
}
|
|
62
|
+
return entrypoint;
|
|
63
|
+
}
|
|
64
|
+
function validateRegistryNodePackage(code, workDir, packageDir, whitelist, translate) {
|
|
65
|
+
const fail = (message) => {
|
|
66
|
+
throw new Error(translate(message));
|
|
67
|
+
};
|
|
68
|
+
const packageRoot = (0, import_fs.realpathSync)(packageDir);
|
|
69
|
+
const workRoot = (0, import_fs.realpathSync)(workDir);
|
|
70
|
+
const checkDirectory = (directory) => {
|
|
71
|
+
for (const entry of (0, import_fs.readdirSync)(directory, { withFileTypes: true })) {
|
|
72
|
+
const path = (0, import_path.resolve)(directory, entry.name);
|
|
73
|
+
if (entry.isSymbolicLink()) {
|
|
74
|
+
fail("Registry Node packages cannot contain symbolic links or bundled node_modules.");
|
|
75
|
+
}
|
|
76
|
+
if (entry.isDirectory()) {
|
|
77
|
+
if (entry.name.toLowerCase() === "node_modules") {
|
|
78
|
+
fail("Registry Node packages cannot contain symbolic links or bundled node_modules.");
|
|
79
|
+
}
|
|
80
|
+
checkDirectory(path);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (!(0, import_fs.lstatSync)(packageDir).isDirectory()) {
|
|
85
|
+
fail("Registry Node package requires must stay inside the package.");
|
|
86
|
+
}
|
|
87
|
+
checkDirectory(packageDir);
|
|
88
|
+
const validator = new import_CodeValidator.CodeValidator();
|
|
89
|
+
const visited = /* @__PURE__ */ new Set();
|
|
90
|
+
const visit = (source, filename) => {
|
|
91
|
+
validator.validate(source, "node", { allowSkillInputFile: filename !== (0, import_path.resolve)(workRoot, "script.js") });
|
|
92
|
+
validator.validateImports(source, "node", whitelist);
|
|
93
|
+
let wrapper;
|
|
94
|
+
try {
|
|
95
|
+
const commonJsSource = source.replace(/^\uFEFF/, "").replace(/^#![^\r\n]*/, "");
|
|
96
|
+
const wrappedSource = `(function(exports, require, module, __filename, __dirname) {
|
|
97
|
+
${commonJsSource}
|
|
98
|
+
});`;
|
|
99
|
+
new import_vm.Script(wrappedSource);
|
|
100
|
+
const parsed = (0, import_acorn.parse)(wrappedSource, { ecmaVersion: "latest" });
|
|
101
|
+
wrapper = parsed.body[0].expression;
|
|
102
|
+
} catch {
|
|
103
|
+
fail("Registry Node packages must use valid CommonJS code and cannot load native modules.");
|
|
104
|
+
}
|
|
105
|
+
const entrypoint = filename === (0, import_path.resolve)(workRoot, "script.js") ? registryNodeEntrypoint(source, translate) : null;
|
|
106
|
+
const requests = [];
|
|
107
|
+
const requireError = "Registry Node packages must use direct require calls with literal, unescaped paths.";
|
|
108
|
+
(0, import_acorn_walk.fullAncestor)(wrapper.body, (node, _state, ancestors) => {
|
|
109
|
+
var _a;
|
|
110
|
+
if (node.type === "Identifier") {
|
|
111
|
+
const identifier = node;
|
|
112
|
+
const parent = ancestors[ancestors.length - 2];
|
|
113
|
+
if (identifier.name === "require") {
|
|
114
|
+
const call = parent;
|
|
115
|
+
if ((parent == null ? void 0 : parent.type) !== "CallExpression" || call.callee !== node || call.optional) fail(requireError);
|
|
116
|
+
}
|
|
117
|
+
if (identifier.name === "module") {
|
|
118
|
+
const member = parent;
|
|
119
|
+
const property = member == null ? void 0 : member.property;
|
|
120
|
+
const isExports = (parent == null ? void 0 : parent.type) === "MemberExpression" && member.object === node && (!member.computed && property.type === "Identifier" && property.name === "exports" || member.computed && property.type === "Literal" && property.value === "exports");
|
|
121
|
+
if (!isExports) fail(requireError);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (node.type === "CallExpression") {
|
|
125
|
+
const call = node;
|
|
126
|
+
if (call.callee.type !== "Identifier" || call.callee.name !== "require") return;
|
|
127
|
+
const argument = call.arguments[0];
|
|
128
|
+
if (call.arguments.length !== 1 || argument.type !== "Literal" || typeof argument.value !== "string" || !entrypoint && ((_a = argument.raw) == null ? void 0 : _a.includes("\\"))) {
|
|
129
|
+
fail(requireError);
|
|
130
|
+
}
|
|
131
|
+
requests.push(argument.value);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
for (const request of requests) {
|
|
135
|
+
if ((0, import_path.isAbsolute)(request) || /^[A-Za-z]:/.test(request) || request.startsWith("#")) {
|
|
136
|
+
fail("Registry Node package requires must stay inside the package.");
|
|
137
|
+
}
|
|
138
|
+
if (![".", ".."].includes(request) && !request.startsWith("./") && !request.startsWith("../")) continue;
|
|
139
|
+
const requestedPath = (0, import_path.resolve)((0, import_path.dirname)(filename), request);
|
|
140
|
+
const requestedRelative = (0, import_path.relative)(packageRoot, requestedPath);
|
|
141
|
+
if (requestedRelative === ".." || requestedRelative.startsWith(`..${import_path.sep}`) || (0, import_path.isAbsolute)(requestedRelative)) {
|
|
142
|
+
fail("Registry Node package requires must stay inside the package.");
|
|
143
|
+
}
|
|
144
|
+
let resolved;
|
|
145
|
+
try {
|
|
146
|
+
resolved = (0, import_fs.realpathSync)((0, import_module.createRequire)(filename).resolve(request));
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (error.code === "MODULE_NOT_FOUND") {
|
|
149
|
+
fail("Registry Node package contains a missing local module.");
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
const inside = (0, import_path.relative)(packageRoot, resolved);
|
|
154
|
+
if (!inside || inside === ".." || inside.startsWith(`..${import_path.sep}`) || (0, import_path.isAbsolute)(inside)) {
|
|
155
|
+
fail("Registry Node package requires must stay inside the package.");
|
|
156
|
+
}
|
|
157
|
+
if (resolved === (0, import_path.resolve)(workRoot, "script.js")) {
|
|
158
|
+
fail("Registry Node package requires must stay inside the package.");
|
|
159
|
+
}
|
|
160
|
+
const extension = (0, import_path.extname)(resolved);
|
|
161
|
+
if (extension === ".node" || extension === ".mjs") {
|
|
162
|
+
fail("Registry Node packages must use valid CommonJS code and cannot load native modules.");
|
|
163
|
+
}
|
|
164
|
+
if (extension === ".json" || visited.has(resolved)) continue;
|
|
165
|
+
visited.add(resolved);
|
|
166
|
+
for (let directory = (0, import_path.dirname)(resolved); extension !== ".cjs"; directory = (0, import_path.dirname)(directory)) {
|
|
167
|
+
const packageJson = (0, import_path.resolve)(directory, "package.json");
|
|
168
|
+
if ((0, import_fs.lstatSync)(directory).isDirectory()) {
|
|
169
|
+
try {
|
|
170
|
+
const metadata = JSON.parse((0, import_fs.readFileSync)(packageJson, "utf8"));
|
|
171
|
+
if (metadata.type === "module") {
|
|
172
|
+
fail("Registry Node packages must use valid CommonJS code and cannot load native modules.");
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
if (error.code !== "ENOENT") throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (directory === packageRoot) break;
|
|
180
|
+
}
|
|
181
|
+
visit((0, import_fs.readFileSync)(resolved, "utf8"), resolved);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
visit(code, (0, import_path.resolve)(workRoot, "script.js"));
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
registryNodeEntrypoint,
|
|
189
|
+
registryNodeWrapper,
|
|
190
|
+
validateRegistryNodePackage
|
|
191
|
+
});
|
|
@@ -36,6 +36,7 @@ var import_harness_runtime_policy = require("../../services/harness-runtime-poli
|
|
|
36
36
|
var import_crypto = require("crypto");
|
|
37
37
|
var import_skill_tool_name = require("../../utils/skill-tool-name");
|
|
38
38
|
var import_json_fields = require("../utils/json-fields");
|
|
39
|
+
var import_registry_node_package = require("../services/registry-node-package");
|
|
39
40
|
class TaskAbortController {
|
|
40
41
|
listeners = [];
|
|
41
42
|
_aborted = false;
|
|
@@ -74,7 +75,7 @@ class SkillExecutionTask {
|
|
|
74
75
|
this.app = app;
|
|
75
76
|
}
|
|
76
77
|
async run() {
|
|
77
|
-
var _a, _b, _c, _d, _e, _f;
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
78
79
|
const skill = this.execution.get("skill") || this.execution.skill;
|
|
79
80
|
const execId = String(this.execution.get("id"));
|
|
80
81
|
const workerId = String(this.execution.get("workerId") || "");
|
|
@@ -169,10 +170,17 @@ class SkillExecutionTask {
|
|
|
169
170
|
`Skill "${skillName}" has no codeTemplate. Add a code file, inline codeTemplate, or bind it to an installed plugin skill.`
|
|
170
171
|
);
|
|
171
172
|
}
|
|
173
|
+
const registryPackageId = skill.get ? skill.get("registryPackageId") : skill.registryPackageId;
|
|
174
|
+
const registryNode = storageType !== "plugin" && language === "node" && !!registryPackageId;
|
|
175
|
+
const translateRegistryError = (message) => {
|
|
176
|
+
var _a2, _b2;
|
|
177
|
+
return ((_b2 = (_a2 = this.app.i18n) == null ? void 0 : _a2.t) == null ? void 0 : _b2.call(_a2, message, { ns: "plugin-agent-orchestrator" })) || message;
|
|
178
|
+
};
|
|
179
|
+
const entrypoint = registryNode ? (0, import_registry_node_package.registryNodeEntrypoint)(rawCodeTemplate, translateRegistryError) : null;
|
|
172
180
|
if (storageType !== "plugin") {
|
|
173
|
-
skillDir = workDir;
|
|
181
|
+
skillDir = entrypoint ? (0, import_path.resolve)(workDir, "skill") : workDir;
|
|
174
182
|
}
|
|
175
|
-
const code = this.renderTemplate(rawCodeTemplate, inputArgs, execId, skillDir);
|
|
183
|
+
const code = entrypoint ? (0, import_registry_node_package.registryNodeWrapper)(entrypoint) : this.renderTemplate(rawCodeTemplate, inputArgs, execId, skillDir);
|
|
176
184
|
const skillDigest = (0, import_crypto.createHash)("sha256").update(code, "utf8").digest("hex");
|
|
177
185
|
if (!await this.updateIfOwned(execId, workerId, { executedCode: code, skillDigest })) {
|
|
178
186
|
abortController.abort();
|
|
@@ -238,8 +246,11 @@ class SkillExecutionTask {
|
|
|
238
246
|
}
|
|
239
247
|
}
|
|
240
248
|
if (storageType !== "plugin") {
|
|
241
|
-
|
|
242
|
-
skillDir
|
|
249
|
+
if (entrypoint) (0, import_fs.rmSync)(skillDir, { recursive: true, force: true });
|
|
250
|
+
this.skillRepoService.copySkillPackageTo(skillName, skillDir);
|
|
251
|
+
}
|
|
252
|
+
if (registryNode) {
|
|
253
|
+
(0, import_registry_node_package.validateRegistryNodePackage)(code, workDir, skillDir, packageWhitelist, translateRegistryError);
|
|
243
254
|
}
|
|
244
255
|
const result = await this.sandboxRunner.execute({
|
|
245
256
|
language,
|
|
@@ -248,6 +259,7 @@ class SkillExecutionTask {
|
|
|
248
259
|
timeoutSeconds: timeoutSeconds || 60,
|
|
249
260
|
maxOutputSizeMb: maxOutputSizeMb || 50,
|
|
250
261
|
skillDir,
|
|
262
|
+
packageSnapshotDir: entrypoint ? skillDir : void 0,
|
|
251
263
|
inputArgs,
|
|
252
264
|
signal: abortController.signal,
|
|
253
265
|
packageWhitelist,
|
|
@@ -313,7 +325,10 @@ class SkillExecutionTask {
|
|
|
313
325
|
`[skill-hub] Execution ${execId} ${status}: skill=${skill.get ? skill.get("name") : skill.name}, language=${language}, duration=${result.durationMs}ms, files=${result.files.length}, outputSize=${this.fileManager.getTotalOutputSize(execId)}bytes`
|
|
314
326
|
);
|
|
315
327
|
} catch (error) {
|
|
316
|
-
|
|
328
|
+
let errorMessage = error instanceof Error ? error.message : String(error);
|
|
329
|
+
if (errorMessage === "Invalid skill package snapshot path.") {
|
|
330
|
+
errorMessage = ((_h = (_g = this.app.i18n) == null ? void 0 : _g.t) == null ? void 0 : _h.call(_g, errorMessage, { ns: "plugin-agent-orchestrator" })) || errorMessage;
|
|
331
|
+
}
|
|
317
332
|
const failed = await this.updateIfOwned(execId, workerId, {
|
|
318
333
|
status: "failed",
|
|
319
334
|
stderr: errorMessage
|
|
@@ -170,6 +170,7 @@ IMPORTANT: If the skill returns file download URLs, you MUST format them as clic
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
try {
|
|
173
|
+
await plugin.assertSkillReviewApproved(skill, runtime, "skill_hub_execute", ctx);
|
|
173
174
|
const normalizedRuntime = normalizeRuntime(runtime);
|
|
174
175
|
const previousRuntime = ctx.runtime;
|
|
175
176
|
if (normalizedRuntime) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "代理协调器",
|
|
5
5
|
"displayName.vi-VN": "Điều phối Agent",
|
|
6
6
|
"description": "Native AI Employee sub-agent monitoring, policy, and memory context layer for NocoBase plugin-ai.",
|
|
7
|
-
"version": "1.2.
|
|
7
|
+
"version": "1.2.1",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"keywords": [
|
|
@@ -31,8 +31,11 @@
|
|
|
31
31
|
"editionLevel": 0
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"acorn": "^8.10.0",
|
|
35
|
+
"acorn-walk": "8.3.4",
|
|
34
36
|
"adm-zip": "^0.5.10",
|
|
35
37
|
"ajv": "^6.12.6",
|
|
38
|
+
"langchain": "1.2.39",
|
|
36
39
|
"zod": "^3.23.0"
|
|
37
40
|
},
|
|
38
41
|
"peerDependencies": {
|
|
@@ -55,7 +58,7 @@
|
|
|
55
58
|
"url": "git+https://github.com/OrgGem/nocobase-beta.git",
|
|
56
59
|
"directory": "packages/plugins/plugin-agent-orchestrator"
|
|
57
60
|
},
|
|
58
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "82e4a5519b826fd9e01303b426adb6981b0c61be",
|
|
59
62
|
"publishConfig": {
|
|
60
63
|
"access": "public",
|
|
61
64
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -1,11 +1,4 @@
|
|
|
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
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import React from 'react';
|
|
11
4
|
import { ExecutionHistory, LoopSettings, SkillManager, SkillMetrics } from './skill-hub';
|
|
@@ -1,11 +1,4 @@
|
|
|
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
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import React, { Suspense } from 'react';
|
|
11
4
|
import { cleanup, render, screen, waitFor } from '@testing-library/react';
|
package/src/client/plugin.tsx
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
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
|
-
*/
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
2
|
|
|
10
3
|
import { Plugin, lazy } from '@nocobase/client';
|
|
11
4
|
import { ExecutionHistoryPage, LoopSettingsPage, SkillDefinitionsPage, SkillMetricsPage } from './SkillPages';
|
|
12
5
|
import { InteractionSchemasProvider } from './skill-hub/tools/InteractionSchemasProvider';
|
|
13
6
|
import { registerSkillLoopCards } from './skill-hub/tools/registerSkillLoopCards';
|
|
7
|
+
import { AutoApprovalProvider } from '../client-v2/auto-approval/AutoApprovalProvider';
|
|
14
8
|
|
|
15
9
|
const RulesPage = lazy(() => import('../client-v2/pages/RulesPage'));
|
|
16
10
|
const TracingPage = lazy(() => import('../client-v2/pages/TracingPage'));
|
|
@@ -26,6 +20,7 @@ const MemoryInspectorPage = lazy(() => import('../client-v2/pages/MemoryInspecto
|
|
|
26
20
|
export class PluginAgentOrchestratorClient extends Plugin {
|
|
27
21
|
async load() {
|
|
28
22
|
(this as any).app.use(InteractionSchemasProvider);
|
|
23
|
+
this.app.use(AutoApprovalProvider);
|
|
29
24
|
|
|
30
25
|
this.app.pluginSettingsManager.add('ai-orchestrator', {
|
|
31
26
|
title: this.t('Agent Orchestrator'),
|