plugin-agent-orchestrator 1.2.0 → 1.2.2
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 +80 -12
- 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/ParallelInterruptActionsPatch.js +132 -0
- 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__/parallel-interrupt-actions.test.ts +342 -0
- 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 +72 -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/ParallelInterruptActionsPatch.ts +164 -0
- 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,161 @@
|
|
|
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
|
+
import type { Context } from '@nocobase/actions';
|
|
11
|
+
import { read } from '../utils/record-utils';
|
|
12
|
+
|
|
13
|
+
const routingFields = ['routingEnabled', 'routingRole', 'routingPrompt', 'llmService', 'model'] as const;
|
|
14
|
+
const identityFields = ['leaderUsername', 'subAgentUsername', 'enabled', 'harnessTag'] as const;
|
|
15
|
+
const bindingFields = [...identityFields, ...routingFields] as const;
|
|
16
|
+
|
|
17
|
+
type RoutingBinding = Partial<Record<(typeof bindingFields)[number], unknown>>;
|
|
18
|
+
|
|
19
|
+
export class RoutingCycleError extends Error {
|
|
20
|
+
readonly status = 400;
|
|
21
|
+
readonly statusCode = 400;
|
|
22
|
+
readonly expose = true;
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super('This binding would create a delegation cycle.');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function nonBlank(value: unknown): value is string {
|
|
30
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function scalarBindingId(value: unknown) {
|
|
34
|
+
return (
|
|
35
|
+
(typeof value === 'string' && Boolean(value.trim())) ||
|
|
36
|
+
(typeof value === 'number' && Number.isSafeInteger(value) && value > 0)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Validate an opted-in binding after partial update values are merged with the stored record. */
|
|
41
|
+
export function routingBindingError(binding: RoutingBinding): string | null {
|
|
42
|
+
if (binding.routingEnabled !== true) return null;
|
|
43
|
+
if (!nonBlank(binding.leaderUsername) || !nonBlank(binding.subAgentUsername)) {
|
|
44
|
+
return 'Routing requires a parent and a target employee.';
|
|
45
|
+
}
|
|
46
|
+
if (binding.leaderUsername.trim() === binding.subAgentUsername.trim()) {
|
|
47
|
+
return 'An employee cannot delegate to itself.';
|
|
48
|
+
}
|
|
49
|
+
if (binding.routingRole !== 'specialist' && binding.routingRole !== 'worker') {
|
|
50
|
+
return 'Choose a routing role for the target employee.';
|
|
51
|
+
}
|
|
52
|
+
if (
|
|
53
|
+
(binding.llmService != null && typeof binding.llmService !== 'string') ||
|
|
54
|
+
(binding.model != null && typeof binding.model !== 'string') ||
|
|
55
|
+
Boolean(nonBlank(binding.llmService)) !== Boolean(nonBlank(binding.model))
|
|
56
|
+
) {
|
|
57
|
+
return 'Select both an LLM service and a model, or leave both empty.';
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
binding.routingPrompt != null &&
|
|
61
|
+
(typeof binding.routingPrompt !== 'string' || binding.routingPrompt.length > 4000)
|
|
62
|
+
) {
|
|
63
|
+
return 'The routing description must be 4000 characters or fewer.';
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Check the enabled routing graph without trusting labels or names generated by a model. */
|
|
69
|
+
export function routingWouldCycle(binding: RoutingBinding, rows: unknown[], excludeId?: unknown): boolean {
|
|
70
|
+
if (binding.routingEnabled !== true || binding.enabled === false) return false;
|
|
71
|
+
if (!nonBlank(binding.leaderUsername) || !nonBlank(binding.subAgentUsername)) return false;
|
|
72
|
+
const parent = binding.leaderUsername.trim();
|
|
73
|
+
const queue = [binding.subAgentUsername.trim()];
|
|
74
|
+
const visited = new Set<string>();
|
|
75
|
+
const edges = rows
|
|
76
|
+
.filter((row) => excludeId == null || String(read(row, 'id')) !== String(excludeId))
|
|
77
|
+
.filter((row) => read(row, 'enabled') !== false && read(row, 'routingEnabled') === true)
|
|
78
|
+
.map((row) => ({ parent: read(row, 'leaderUsername'), target: read(row, 'subAgentUsername') }))
|
|
79
|
+
.filter((edge): edge is { parent: string; target: string } => nonBlank(edge.parent) && nonBlank(edge.target));
|
|
80
|
+
while (queue.length) {
|
|
81
|
+
const current = queue.shift();
|
|
82
|
+
if (!current) continue;
|
|
83
|
+
if (current === parent) return true;
|
|
84
|
+
if (visited.has(current)) continue;
|
|
85
|
+
visited.add(current);
|
|
86
|
+
for (const edge of edges) {
|
|
87
|
+
if (edge.parent.trim() === current) queue.push(edge.target.trim());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Run after ACL so this validation cannot replace collection or association authorization. */
|
|
94
|
+
async function validateRoutingBinding(ctx: Context, next: () => Promise<unknown>) {
|
|
95
|
+
const { resourceName, actionName, params } = ctx.action || {};
|
|
96
|
+
if (resourceName !== 'orchestratorConfig' || !['create', 'update'].includes(actionName)) return next();
|
|
97
|
+
const values = params?.values;
|
|
98
|
+
if (!values || typeof values !== 'object') return next();
|
|
99
|
+
if (Array.isArray(values)) {
|
|
100
|
+
if (
|
|
101
|
+
values.some(
|
|
102
|
+
(item) =>
|
|
103
|
+
item && typeof item === 'object' && [...routingFields, ...identityFields].some((field) => field in item),
|
|
104
|
+
)
|
|
105
|
+
) {
|
|
106
|
+
return ctx.throw(400, ctx.t('Update routing settings for one binding at a time.'));
|
|
107
|
+
}
|
|
108
|
+
return next();
|
|
109
|
+
}
|
|
110
|
+
const patch = values as RoutingBinding;
|
|
111
|
+
if ('routingEnabled' in patch && typeof patch.routingEnabled !== 'boolean') {
|
|
112
|
+
return ctx.throw(400, ctx.t('Routing enabled must be a boolean.'));
|
|
113
|
+
}
|
|
114
|
+
let current: unknown;
|
|
115
|
+
if (actionName === 'update') {
|
|
116
|
+
const key = params.filterByTk;
|
|
117
|
+
if (!scalarBindingId(key)) {
|
|
118
|
+
if (routingFields.some((field) => field in patch)) {
|
|
119
|
+
return ctx.throw(400, ctx.t('Update routing settings for one binding at a time.'));
|
|
120
|
+
}
|
|
121
|
+
if (identityFields.some((field) => field in patch)) {
|
|
122
|
+
if (key != null && (!Array.isArray(key) || !key.length || !key.every(scalarBindingId))) {
|
|
123
|
+
return ctx.throw(400, ctx.t('Update routing settings for one binding at a time.'));
|
|
124
|
+
}
|
|
125
|
+
const filter = params.filter && typeof params.filter === 'object' ? params.filter : {};
|
|
126
|
+
const targets = Array.isArray(key) ? { id: key } : {};
|
|
127
|
+
const affected = await ctx.db.getRepository('orchestratorConfig').findOne({
|
|
128
|
+
filter: { $and: [filter, targets, { routingEnabled: true }] },
|
|
129
|
+
});
|
|
130
|
+
if (affected) return ctx.throw(400, ctx.t('Update routing settings for one binding at a time.'));
|
|
131
|
+
}
|
|
132
|
+
return next();
|
|
133
|
+
}
|
|
134
|
+
current = await ctx.db.getRepository('orchestratorConfig').findOne({ filterByTk: key });
|
|
135
|
+
if (!current) return next();
|
|
136
|
+
}
|
|
137
|
+
const merged: RoutingBinding = {};
|
|
138
|
+
for (const field of bindingFields) {
|
|
139
|
+
merged[field] = field in patch ? patch[field] : read(current, field);
|
|
140
|
+
}
|
|
141
|
+
const error = routingBindingError(merged);
|
|
142
|
+
if (error) return ctx.throw(400, ctx.t(error));
|
|
143
|
+
if (merged.routingEnabled === true && merged.enabled !== false) {
|
|
144
|
+
const rows = await ctx.db.getRepository('orchestratorConfig').find({
|
|
145
|
+
filter: { routingEnabled: true, enabled: true },
|
|
146
|
+
});
|
|
147
|
+
if (routingWouldCycle(merged, rows, actionName === 'update' ? params.filterByTk : undefined)) {
|
|
148
|
+
return ctx.throw(400, ctx.t('This binding would create a delegation cycle.'));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return next();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function validateRoutingBindingAction(ctx: Context, next: () => Promise<unknown>) {
|
|
155
|
+
try {
|
|
156
|
+
return await validateRoutingBinding(ctx, next);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error instanceof RoutingCycleError) return ctx.throw(400, ctx.t(error.message));
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
1
10
|
import { spawn } from 'child_process';
|
|
2
|
-
import { existsSync, writeFileSync } from 'fs';
|
|
11
|
+
import { chownSync, existsSync, lstatSync, readdirSync, realpathSync, writeFileSync } from 'fs';
|
|
3
12
|
import { resolve, delimiter } from 'path';
|
|
4
13
|
import { tmpdir } from 'os';
|
|
5
14
|
import { FileManager, OutputFileInfo } from './FileManager';
|
|
@@ -39,6 +48,8 @@ export interface ExecuteOptions {
|
|
|
39
48
|
packageWhitelist?: string[];
|
|
40
49
|
/** Optional installed/copied skill package root exposed to the runtime as SKILL_DIR. */
|
|
41
50
|
skillDir?: string;
|
|
51
|
+
/** Private package snapshot inside the execution directory, if it needs a privilege-drop owner. */
|
|
52
|
+
packageSnapshotDir?: string;
|
|
42
53
|
/** Validated input exposed as a JSON file to avoid source-code interpolation. */
|
|
43
54
|
inputArgs?: Record<string, unknown>;
|
|
44
55
|
}
|
|
@@ -198,6 +209,7 @@ export class SandboxRunner {
|
|
|
198
209
|
signal,
|
|
199
210
|
packageWhitelist,
|
|
200
211
|
skillDir,
|
|
212
|
+
packageSnapshotDir,
|
|
201
213
|
inputArgs,
|
|
202
214
|
} = options;
|
|
203
215
|
|
|
@@ -230,8 +242,30 @@ export class SandboxRunner {
|
|
|
230
242
|
: null;
|
|
231
243
|
if (identity) {
|
|
232
244
|
try {
|
|
245
|
+
const snapshotPaths: string[] = [];
|
|
246
|
+
if (packageSnapshotDir) {
|
|
247
|
+
const expected = resolve(workDir, 'skill');
|
|
248
|
+
if (
|
|
249
|
+
resolve(packageSnapshotDir) !== expected ||
|
|
250
|
+
lstatSync(packageSnapshotDir).isSymbolicLink() ||
|
|
251
|
+
realpathSync(packageSnapshotDir) !== resolve(realpathSync(workDir), 'skill')
|
|
252
|
+
) {
|
|
253
|
+
throw new Error('Invalid skill package snapshot path.');
|
|
254
|
+
}
|
|
255
|
+
const collect = (path: string) => {
|
|
256
|
+
const stat = lstatSync(path);
|
|
257
|
+
if (stat.isSymbolicLink()) throw new Error('Invalid skill package snapshot path.');
|
|
258
|
+
snapshotPaths.push(path);
|
|
259
|
+
if (stat.isDirectory()) {
|
|
260
|
+
for (const entry of readdirSync(path)) collect(resolve(path, entry));
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
collect(packageSnapshotDir);
|
|
264
|
+
}
|
|
233
265
|
this.fileManager.chownExecDir(execId, identity.uid, identity.gid);
|
|
266
|
+
for (const path of snapshotPaths) chownSync(path, identity.uid, identity.gid);
|
|
234
267
|
} catch (error) {
|
|
268
|
+
if (packageSnapshotDir) throw error;
|
|
235
269
|
this.logger.warn(
|
|
236
270
|
`[skill-hub] chown of exec dir failed for ${execId}; running without privilege drop: ${
|
|
237
271
|
(error as Error).message
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import type { Context, Next } from '@nocobase/actions';
|
|
3
|
+
import type { Filter, Model } from '@nocobase/database';
|
|
4
|
+
import { getAIToolsManager } from '../utils/ai-manager';
|
|
5
|
+
import { asRecord, read } from '../utils/record-utils';
|
|
6
|
+
import { getSkillToolName } from '../utils/skill-tool-name';
|
|
7
|
+
import { parseJsonText } from '../skill-hub/utils/json-fields';
|
|
8
|
+
import {
|
|
9
|
+
autoApprovalCheckpoint,
|
|
10
|
+
coordinateAutoApprovalDecision,
|
|
11
|
+
enrollAutoApprovalCheckpoint,
|
|
12
|
+
} from './AutoApprovalCheckpoint';
|
|
13
|
+
|
|
14
|
+
const interactiveTools = new Set(['suggestions', 'aiEmployeeWorkflowTaskOutput']);
|
|
15
|
+
|
|
16
|
+
export type AutoApprovalCall = { sessionId: string; messageId: string; toolCallId: string };
|
|
17
|
+
|
|
18
|
+
export function autoApprovalCall(values: Record<string, unknown>): AutoApprovalCall | null {
|
|
19
|
+
const { sessionId, messageId, toolCallId } = values;
|
|
20
|
+
if (typeof sessionId !== 'string' || !sessionId.trim() || sessionId.length > 100) return null;
|
|
21
|
+
if (
|
|
22
|
+
!(
|
|
23
|
+
(typeof messageId === 'string' && messageId.trim()) ||
|
|
24
|
+
(typeof messageId === 'number' && Number.isSafeInteger(messageId) && messageId > 0)
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
return null;
|
|
28
|
+
if (typeof toolCallId !== 'string' || !toolCallId.trim()) return null;
|
|
29
|
+
return { sessionId, messageId: String(messageId), toolCallId };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The caller must already have verified access to the root conversation. */
|
|
33
|
+
export async function sessionAutoApprovalEnabled(ctx: Context, sessionId: string): Promise<boolean> {
|
|
34
|
+
const ownerId = ctx.auth?.user?.id;
|
|
35
|
+
if (!ownerId || !sessionId) return false;
|
|
36
|
+
const setting = await ctx.db.getRepository('agentSessionAutoApprovals').findOne({
|
|
37
|
+
filter: { ownerId, sessionId },
|
|
38
|
+
});
|
|
39
|
+
return read(setting, 'enabled') === true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Skill Hub interaction schemas request user input and must not be filled by an approval. */
|
|
43
|
+
export async function skillRequiresUserInput(ctx: Context, name: string, args: unknown): Promise<boolean> {
|
|
44
|
+
const repository = ctx.db.getRepository('skillDefinitions');
|
|
45
|
+
let skill;
|
|
46
|
+
if (name === 'skill_hub_execute') {
|
|
47
|
+
const input = asRecord(args);
|
|
48
|
+
if (input.action === 'list' || input.action === 'describe') return false;
|
|
49
|
+
if (input.action !== 'execute' || typeof input.skillName !== 'string' || !input.skillName) return true;
|
|
50
|
+
skill = await repository.findOne({ filter: { name: input.skillName, enabled: true } });
|
|
51
|
+
if (!skill) return true;
|
|
52
|
+
} else {
|
|
53
|
+
skill = await repository.findOne({ filter: { toolName: name, enabled: true } });
|
|
54
|
+
if (!skill && name.startsWith('skill_hub_')) {
|
|
55
|
+
const legacy = await repository.find({ filter: { enabled: true } });
|
|
56
|
+
skill = legacy.find((item: Model) => {
|
|
57
|
+
try {
|
|
58
|
+
return getSkillToolName(item) === name;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!skill) return false;
|
|
65
|
+
}
|
|
66
|
+
const skillId = read(skill, 'id');
|
|
67
|
+
if (typeof skillId !== 'number' && typeof skillId !== 'string') return true;
|
|
68
|
+
const loop = await ctx.db.getRepository('skillLoopConfigs').findOne({
|
|
69
|
+
filter: { enabled: true, skillId },
|
|
70
|
+
sort: ['-updatedAt'],
|
|
71
|
+
});
|
|
72
|
+
const loopSchema = parseJsonText<unknown>(read(loop, 'schema'), null);
|
|
73
|
+
if ((loopSchema && typeof loopSchema === 'object') || read(loop, 'prompt')) return true;
|
|
74
|
+
return Boolean(parseJsonText<unknown>(read(skill, 'interactionSchema'), null));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Verify the persisted root interrupt rather than trusting the event sent to the browser. */
|
|
78
|
+
export async function isAutoApprovalEligible(ctx: Context, call: AutoApprovalCall): Promise<boolean> {
|
|
79
|
+
const ownerId = ctx.auth?.user?.id;
|
|
80
|
+
if (!ownerId || !(await sessionAutoApprovalEnabled(ctx, call.sessionId))) return false;
|
|
81
|
+
const conversation = await ctx.db.getRepository('aiConversations').findOne({
|
|
82
|
+
filter: { sessionId: call.sessionId, userId: ownerId },
|
|
83
|
+
});
|
|
84
|
+
if (!conversation || read(conversation, 'from') === 'sub-agent') return false;
|
|
85
|
+
const username = read(conversation, 'aiEmployeeUsername');
|
|
86
|
+
if (typeof username !== 'string' || !username) return false;
|
|
87
|
+
const requestedRoles = ctx.state.currentRoles;
|
|
88
|
+
if (!Array.isArray(requestedRoles)) return false;
|
|
89
|
+
const memberships = await ctx.db.getRepository('rolesUsers').find({ filter: { userId: ownerId } });
|
|
90
|
+
const memberRoles = new Set(memberships.map((row: Model) => read(row, 'roleName')));
|
|
91
|
+
const roles = requestedRoles.filter(
|
|
92
|
+
(role: unknown): role is string => typeof role === 'string' && memberRoles.has(role),
|
|
93
|
+
);
|
|
94
|
+
if (!roles.length) return false;
|
|
95
|
+
if (
|
|
96
|
+
typeof ctx.state.currentRole === 'string' &&
|
|
97
|
+
ctx.state.currentRole !== '__union__' &&
|
|
98
|
+
!roles.includes(ctx.state.currentRole)
|
|
99
|
+
)
|
|
100
|
+
return false;
|
|
101
|
+
const filter: Filter = { username };
|
|
102
|
+
if (!roles.includes('root')) filter['roles.name'] = roles;
|
|
103
|
+
const employee = await ctx.db.getRepository('aiEmployees').findOne({ filter });
|
|
104
|
+
if (!employee || read(employee, 'enabled') === false) return false;
|
|
105
|
+
const message = await ctx.db.getRepository('aiMessages').findOne({
|
|
106
|
+
filter: { sessionId: call.sessionId, messageId: call.messageId, role: username },
|
|
107
|
+
});
|
|
108
|
+
const calls = read(message, 'toolCalls');
|
|
109
|
+
const selected = Array.isArray(calls) ? calls.map(asRecord).find((item) => item.id === call.toolCallId) : undefined;
|
|
110
|
+
const name = selected?.name;
|
|
111
|
+
if (typeof name !== 'string' || !name || interactiveTools.has(name)) return false;
|
|
112
|
+
if (await skillRequiresUserInput(ctx, name, selected.args)) return false;
|
|
113
|
+
const tool = await ctx.db.getRepository('aiToolMessages').findOne({
|
|
114
|
+
filter: { ...call, toolName: name, invokeStatus: 'interrupted' },
|
|
115
|
+
});
|
|
116
|
+
if (!tool || read(tool, 'auto') !== false || read(tool, 'status') === 'error') return false;
|
|
117
|
+
const interrupt = asRecord(read(tool, 'interruptAction'));
|
|
118
|
+
const interruptCall = asRecord(interrupt.toolCall);
|
|
119
|
+
const interruptedConversation = asRecord(interrupt.currentConversation);
|
|
120
|
+
const metadata = asRecord(read(message, 'metadata'));
|
|
121
|
+
if (
|
|
122
|
+
!Array.isArray(interrupt.allowedDecisions) ||
|
|
123
|
+
!interrupt.allowedDecisions.includes('approve') ||
|
|
124
|
+
interruptCall.id !== call.toolCallId ||
|
|
125
|
+
interruptCall.name !== name ||
|
|
126
|
+
interruptedConversation.sessionId !== call.sessionId ||
|
|
127
|
+
interruptedConversation.from !== 'main-agent' ||
|
|
128
|
+
interruptedConversation.username !== username ||
|
|
129
|
+
typeof metadata.interruptId !== 'string' ||
|
|
130
|
+
!metadata.interruptId
|
|
131
|
+
)
|
|
132
|
+
return false;
|
|
133
|
+
const entry = await getAIToolsManager(ctx.app).getTools(name, { ctx, sessionId: call.sessionId });
|
|
134
|
+
if (!entry || typeof entry.invoke !== 'function') return false;
|
|
135
|
+
if (name === 'executeFrontendTool') {
|
|
136
|
+
const toolId = asRecord(selected.args).toolId;
|
|
137
|
+
const options = asRecord(read(conversation, 'options'));
|
|
138
|
+
const tools = options.frontendTools;
|
|
139
|
+
if (typeof toolId !== 'string' || !Array.isArray(tools)) return false;
|
|
140
|
+
return tools
|
|
141
|
+
.map(asRecord)
|
|
142
|
+
.some((tool) => tool.id === toolId && tool.id === `${tool.blockUid}:${tool.name}` && tool.permission === 'ASK');
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Marked automatic decisions are rechecked as the native action receives them. */
|
|
148
|
+
export async function guardAutoApprovalDecision(ctx: Context, next: Next) {
|
|
149
|
+
if (ctx.action?.resourceName !== 'aiConversations' || ctx.action.actionName !== 'updateUserDecision') return next();
|
|
150
|
+
const values = asRecord(ctx.action.params?.values);
|
|
151
|
+
const automatic = values.agentAutoApproval === true;
|
|
152
|
+
const decision = asRecord(values.userDecision);
|
|
153
|
+
const call = autoApprovalCall(values);
|
|
154
|
+
if (automatic && (!call || decision.type !== 'approve' || !(await isAutoApprovalEligible(ctx, call)))) {
|
|
155
|
+
ctx.body = { updated: 0, toolCalls: [] };
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!call) return next();
|
|
159
|
+
const checkpoint = await autoApprovalCheckpoint(ctx, call);
|
|
160
|
+
if (automatic && checkpoint === undefined) {
|
|
161
|
+
ctx.body = { updated: 0, toolCalls: [] };
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (automatic && checkpoint) await enrollAutoApprovalCheckpoint(ctx, checkpoint);
|
|
165
|
+
await next();
|
|
166
|
+
if (checkpoint) await coordinateAutoApprovalDecision(ctx, checkpoint, call);
|
|
167
|
+
}
|
|
@@ -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 { read } from '../utils/record-utils';
|
|
11
4
|
|
|
@@ -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
|
function positiveDays(value: unknown): number | null {
|
|
11
4
|
const days = typeof value === 'number' ? value : Number(value);
|
|
@@ -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 type { Database, Model } from '@nocobase/database';
|
|
11
4
|
import type { CompiledHarness } from './HarnessCompiler';
|
|
@@ -156,7 +149,7 @@ export class VerificationService {
|
|
|
156
149
|
eventType: 'run_verified',
|
|
157
150
|
title: `Verifier returned ${verdict.verdict}`,
|
|
158
151
|
content: verdict.summary,
|
|
159
|
-
correlationKey: `verified:${input.
|
|
152
|
+
correlationKey: `verified:${input.leaseToken}`,
|
|
160
153
|
values: {
|
|
161
154
|
verifierVerdict: verdict.verdict,
|
|
162
155
|
verifierEvidence: verdict,
|
|
@@ -201,7 +194,7 @@ export class VerificationService {
|
|
|
201
194
|
eventType: finding.level === 'block' ? 'run_blocked' : 'run_escalated',
|
|
202
195
|
title: finding.level === 'block' ? 'Run blocked by tool loop detection' : 'Run escalated by tool loop detection',
|
|
203
196
|
content: reason,
|
|
204
|
-
correlationKey: `tool-loop-${finding.level}:${input.
|
|
197
|
+
correlationKey: `tool-loop-${finding.level}:${input.leaseToken}`,
|
|
205
198
|
values: finding.level === 'block' ? { blockedReason: reason } : { escalationReason: reason },
|
|
206
199
|
});
|
|
207
200
|
return 'halt';
|
|
@@ -1,3 +1,12 @@
|
|
|
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
|
+
|
|
1
10
|
import { resolve } from 'path';
|
|
2
11
|
import { createReadStream, createWriteStream, unlinkSync } from 'fs';
|
|
3
12
|
import * as os from 'os';
|
|
@@ -886,6 +895,36 @@ export class SkillHubSubFeature {
|
|
|
886
895
|
return configsBySkillId;
|
|
887
896
|
}
|
|
888
897
|
|
|
898
|
+
async assertSkillReviewApproved(
|
|
899
|
+
skill: unknown,
|
|
900
|
+
runtime: ToolRuntimeInput,
|
|
901
|
+
toolName: string,
|
|
902
|
+
ctx?: { t?: (key: string, options: { ns: string }) => string },
|
|
903
|
+
) {
|
|
904
|
+
const loopConfig = await this.db.getRepository('skillLoopConfigs').findOne({
|
|
905
|
+
filter: { enabled: true, skillId: this.getSkillRecordId(skill) },
|
|
906
|
+
sort: ['-updatedAt'],
|
|
907
|
+
});
|
|
908
|
+
const interactionSchema =
|
|
909
|
+
this.resolveLoopInteractionSchema(loopConfig) || parseJsonText(readRecordValue(skill, 'interactionSchema'), null);
|
|
910
|
+
if (!interactionSchema) return;
|
|
911
|
+
|
|
912
|
+
const toolCallId = normalizeToolRuntime(runtime)?.toolCallId;
|
|
913
|
+
const call = toolCallId
|
|
914
|
+
? await this.db.getRepository('aiToolMessages').findOne({ filter: { toolCallId, toolName } })
|
|
915
|
+
: null;
|
|
916
|
+
const decision = readRecordValue(readRecordValue(call, 'userDecision'), 'type');
|
|
917
|
+
if (
|
|
918
|
+
readRecordValue(call, 'auto') !== false ||
|
|
919
|
+
readRecordValue(call, 'invokeStatus') !== 'pending' ||
|
|
920
|
+
(decision !== 'approve' && decision !== 'edit')
|
|
921
|
+
) {
|
|
922
|
+
const message =
|
|
923
|
+
'Human review is required for this skill. Disable Auto call and approve the tool call before execution.';
|
|
924
|
+
throw new Error(ctx?.t?.(message, { ns: 'plugin-agent-orchestrator' }) || message);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
889
928
|
private registerAITools() {
|
|
890
929
|
try {
|
|
891
930
|
// Register on the SAME tools manager the harness resolves from
|
|
@@ -952,6 +991,7 @@ export class SkillHubSubFeature {
|
|
|
952
991
|
if (!latestSkill) {
|
|
953
992
|
return { status: 'error', content: `Skill "${skill.get('name')}" is no longer available` };
|
|
954
993
|
}
|
|
994
|
+
await this.assertSkillReviewApproved(latestSkill, runtime, getSkillToolName(skill), toolCtx);
|
|
955
995
|
const result = await this.executeSkill(latestSkill, args, toolCtx);
|
|
956
996
|
return {
|
|
957
997
|
status: result.status === 'succeeded' ? 'success' : 'error',
|
|
@@ -1,9 +1,19 @@
|
|
|
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
|
+
|
|
1
10
|
import { createHash } from 'crypto';
|
|
2
11
|
|
|
3
12
|
import type { Database } from '@nocobase/database';
|
|
4
13
|
|
|
5
14
|
import type { SkillRepositoryService } from '../../services/SkillRepositoryService';
|
|
6
15
|
import { assertSkillToolNameAvailable, buildSkillToolName } from '../../utils/skill-tool-name';
|
|
16
|
+
import { registryNodeWrapper } from './registry-node-package';
|
|
7
17
|
|
|
8
18
|
export interface RegistryInstallationInput {
|
|
9
19
|
registryPackageId: string | number;
|
|
@@ -84,7 +94,7 @@ function executionWrapper(runtime: 'python' | 'node', entrypoint: string): strin
|
|
|
84
94
|
'',
|
|
85
95
|
].join('\n');
|
|
86
96
|
}
|
|
87
|
-
return
|
|
97
|
+
return registryNodeWrapper(entrypoint);
|
|
88
98
|
}
|
|
89
99
|
|
|
90
100
|
export class RegistrySkillInstallationService {
|