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
|
@@ -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 React, { createContext, useContext, useEffect, useState } from 'react';
|
|
2
11
|
import { useApp } from '@nocobase/client-v2';
|
|
3
12
|
import { parseJsonText } from '../utils/jsonFields';
|
|
@@ -62,7 +71,7 @@ export const InteractionSchemasProvider: React.FC<{ children?: React.ReactNode }
|
|
|
62
71
|
};
|
|
63
72
|
const schemaFromLoopConfig = (config: any): InteractionSchema | null => {
|
|
64
73
|
const schema = parseJsonText<InteractionSchema | null>(config.schema, null);
|
|
65
|
-
if (schema) {
|
|
74
|
+
if (schema && typeof schema === 'object') {
|
|
66
75
|
return config.prompt && !schema.prompt ? { ...schema, prompt: config.prompt } : schema;
|
|
67
76
|
}
|
|
68
77
|
if (config.prompt) {
|
|
@@ -80,7 +89,7 @@ export const InteractionSchemasProvider: React.FC<{ children?: React.ReactNode }
|
|
|
80
89
|
skipNotify: true,
|
|
81
90
|
params: {
|
|
82
91
|
filter: { enabled: true },
|
|
83
|
-
fields: ['id', 'name', 'autoCall', 'interactionSchema'],
|
|
92
|
+
fields: ['id', 'name', 'toolName', 'autoCall', 'interactionSchema'],
|
|
84
93
|
pageSize: 500,
|
|
85
94
|
},
|
|
86
95
|
}),
|
|
@@ -91,6 +100,7 @@ export const InteractionSchemasProvider: React.FC<{ children?: React.ReactNode }
|
|
|
91
100
|
params: {
|
|
92
101
|
filter: { enabled: true },
|
|
93
102
|
fields: ['skillId', 'enabled', 'schema', 'prompt', 'templateKey'],
|
|
103
|
+
sort: ['-updatedAt'],
|
|
94
104
|
pageSize: 500,
|
|
95
105
|
},
|
|
96
106
|
})
|
|
@@ -104,18 +114,23 @@ export const InteractionSchemasProvider: React.FC<{ children?: React.ReactNode }
|
|
|
104
114
|
const skillsById = new Map(skills.map((skill: any) => [String(skill.id), skill]));
|
|
105
115
|
|
|
106
116
|
for (const s of skills) {
|
|
107
|
-
if (s.autoCall) continue;
|
|
108
117
|
const schema = parseJsonText<InteractionSchema | null>(s.interactionSchema, null);
|
|
109
118
|
if (!schema) continue;
|
|
110
|
-
next.set(
|
|
119
|
+
next.set(`skill:${s.name}`, schema);
|
|
120
|
+
next.set(`tool:${s.toolName?.trim() || `skill_hub_${sanitize(s.name)}`}`, schema);
|
|
111
121
|
}
|
|
112
122
|
|
|
123
|
+
const seenSkillIds = new Set<string>();
|
|
113
124
|
for (const config of loopConfigs) {
|
|
114
|
-
const
|
|
125
|
+
const skillId = String(config.skillId);
|
|
126
|
+
if (seenSkillIds.has(skillId)) continue;
|
|
127
|
+
seenSkillIds.add(skillId);
|
|
128
|
+
const skill = skillsById.get(skillId);
|
|
115
129
|
if (!skill?.name) continue;
|
|
116
130
|
const schema = schemaFromLoopConfig(config);
|
|
117
131
|
if (!schema) continue;
|
|
118
|
-
next.set(
|
|
132
|
+
next.set(`skill:${skill.name}`, schema);
|
|
133
|
+
next.set(`tool:${skill.toolName?.trim() || `skill_hub_${sanitize(skill.name)}`}`, schema);
|
|
119
134
|
}
|
|
120
135
|
|
|
121
136
|
setMap(next);
|
|
@@ -1,21 +1,29 @@
|
|
|
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 React from 'react';
|
|
2
11
|
import { Form, Input, Select, Radio, InputNumber, Button, Space, Card, Typography } from 'antd';
|
|
3
12
|
import { ToolsUIProperties } from '@nocobase/client';
|
|
4
13
|
import { useInteractionSchemas } from './InteractionSchemasProvider';
|
|
14
|
+
import type { InteractionSchema } from './loopTemplates';
|
|
5
15
|
|
|
6
16
|
export const SkillHubCard: React.FC<ToolsUIProperties> = ({ toolCall, decisions }) => {
|
|
7
17
|
const schemas = useInteractionSchemas();
|
|
8
18
|
const [form] = Form.useForm();
|
|
9
19
|
|
|
10
|
-
const sanitize = (name: string) =>
|
|
11
|
-
name
|
|
12
|
-
.toLowerCase()
|
|
13
|
-
.replace(/[^a-z0-9_]/g, '_')
|
|
14
|
-
.replace(/_+/g, '_')
|
|
15
|
-
.replace(/^_|_$/g, '');
|
|
16
20
|
const isGenericExecutor = toolCall.name === 'skill_hub_execute';
|
|
17
|
-
const rawArgs = (toolCall.args as Record<string,
|
|
18
|
-
const
|
|
21
|
+
const rawArgs = (toolCall.args as Record<string, unknown>) || {};
|
|
22
|
+
const input =
|
|
23
|
+
rawArgs.input && typeof rawArgs.input === 'object' && !Array.isArray(rawArgs.input) ? rawArgs.input : {};
|
|
24
|
+
const skillKey = isGenericExecutor
|
|
25
|
+
? `skill:${typeof rawArgs.skillName === 'string' ? rawArgs.skillName : ''}`
|
|
26
|
+
: `tool:${toolCall.name}`;
|
|
19
27
|
const schema = schemas.get(skillKey);
|
|
20
28
|
|
|
21
29
|
const interrupted = toolCall.invokeStatus === 'init' || toolCall.invokeStatus === 'interrupted';
|
|
@@ -44,17 +52,15 @@ export const SkillHubCard: React.FC<ToolsUIProperties> = ({ toolCall, decisions
|
|
|
44
52
|
const args = isGenericExecutor
|
|
45
53
|
? {
|
|
46
54
|
...rawArgs,
|
|
47
|
-
input:
|
|
55
|
+
input: { ...input, ...values },
|
|
48
56
|
}
|
|
49
|
-
:
|
|
50
|
-
? values
|
|
51
|
-
: { ...rawArgs, ...values };
|
|
57
|
+
: { ...rawArgs, ...values };
|
|
52
58
|
await decisions.edit(args);
|
|
53
59
|
};
|
|
54
60
|
|
|
55
|
-
const renderField = (
|
|
61
|
+
const renderField = (f: NonNullable<InteractionSchema['fields']>[string]) => {
|
|
56
62
|
if (f?.enum) {
|
|
57
|
-
return <Select options={f.enum.map((v
|
|
63
|
+
return <Select options={f.enum.map((v) => ({ value: v, label: String(v) }))} />;
|
|
58
64
|
}
|
|
59
65
|
if (f?.type === 'number' || f?.type === 'integer') {
|
|
60
66
|
return <InputNumber style={{ width: '100%' }} />;
|
|
@@ -70,7 +76,7 @@ export const SkillHubCard: React.FC<ToolsUIProperties> = ({ toolCall, decisions
|
|
|
70
76
|
<Form
|
|
71
77
|
form={form}
|
|
72
78
|
layout="vertical"
|
|
73
|
-
initialValues={
|
|
79
|
+
initialValues={isGenericExecutor ? input : rawArgs}
|
|
74
80
|
style={{ marginBottom: 8 }}
|
|
75
81
|
>
|
|
76
82
|
{schema.type === 'select' && (
|
|
@@ -87,7 +93,7 @@ export const SkillHubCard: React.FC<ToolsUIProperties> = ({ toolCall, decisions
|
|
|
87
93
|
{schema.type === 'form' &&
|
|
88
94
|
Object.entries(schema.fields ?? {}).map(([key, f]) => (
|
|
89
95
|
<Form.Item key={key} name={key} label={f.title || key} rules={[{ required: !!f.required }]}>
|
|
90
|
-
{renderField(
|
|
96
|
+
{renderField(f)}
|
|
91
97
|
</Form.Item>
|
|
92
98
|
))}
|
|
93
99
|
</Form>
|
|
@@ -0,0 +1,255 @@
|
|
|
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 React from 'react';
|
|
11
|
+
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
12
|
+
import * as ClientV2 from '@nocobase/client-v2';
|
|
13
|
+
import { AxiosHeaders } from 'axios';
|
|
14
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
15
|
+
import { InteractionSchemasProvider } from '../InteractionSchemasProvider';
|
|
16
|
+
import { registerSkillLoopCards } from '../registerSkillLoopCards';
|
|
17
|
+
import { SkillHubCard } from '../SkillHubCard';
|
|
18
|
+
|
|
19
|
+
const skillDefinitions = [
|
|
20
|
+
{
|
|
21
|
+
id: 1,
|
|
22
|
+
name: 'Renamed & Skill',
|
|
23
|
+
toolName: 'skill_hub_original_identity',
|
|
24
|
+
autoCall: true,
|
|
25
|
+
interactionSchema: {
|
|
26
|
+
type: 'select',
|
|
27
|
+
prompt: 'Choose native input',
|
|
28
|
+
options: [
|
|
29
|
+
{ label: 'Native old', value: 'old' },
|
|
30
|
+
{ label: 'Native new', value: 'new' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 2,
|
|
36
|
+
name: 'Legacy Skill',
|
|
37
|
+
autoCall: true,
|
|
38
|
+
interactionSchema: {
|
|
39
|
+
type: 'select',
|
|
40
|
+
prompt: 'Choose generic input',
|
|
41
|
+
options: [
|
|
42
|
+
{ label: 'Generic old', value: 'old' },
|
|
43
|
+
{ label: 'Generic new', value: 'new' },
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
function cardProps(
|
|
50
|
+
name: string,
|
|
51
|
+
args: Record<string, unknown>,
|
|
52
|
+
edit: ReturnType<typeof vi.fn>,
|
|
53
|
+
): React.ComponentProps<typeof SkillHubCard> {
|
|
54
|
+
return {
|
|
55
|
+
messageId: 'message-1',
|
|
56
|
+
tools: {} as React.ComponentProps<typeof SkillHubCard>['tools'],
|
|
57
|
+
toolCall: {
|
|
58
|
+
id: name,
|
|
59
|
+
type: 'function',
|
|
60
|
+
name,
|
|
61
|
+
invokeStatus: 'interrupted',
|
|
62
|
+
auto: false,
|
|
63
|
+
args,
|
|
64
|
+
},
|
|
65
|
+
decisions: {
|
|
66
|
+
approve: vi.fn(async () => {}),
|
|
67
|
+
edit,
|
|
68
|
+
reject: vi.fn(async () => {}),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
vi.spyOn(window, 'matchMedia').mockImplementation((media) => ({
|
|
75
|
+
matches: false,
|
|
76
|
+
media,
|
|
77
|
+
onchange: null,
|
|
78
|
+
addListener: () => {},
|
|
79
|
+
removeListener: () => {},
|
|
80
|
+
addEventListener: () => {},
|
|
81
|
+
removeEventListener: () => {},
|
|
82
|
+
dispatchEvent: () => false,
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
afterEach(() => {
|
|
87
|
+
cleanup();
|
|
88
|
+
vi.restoreAllMocks();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('v1 Skill Hub card interactions', () => {
|
|
92
|
+
it('preserves native and generic inputs when a select schema edits the choice', async () => {
|
|
93
|
+
const app = ClientV2.createMockClient();
|
|
94
|
+
app.apiClient.auth.setToken('test-token');
|
|
95
|
+
let loopConfigs: Array<{ skillId: string | number; schema?: unknown; prompt?: string }> = [];
|
|
96
|
+
const request = vi.spyOn(app.apiClient, 'request').mockImplementation(async (config) => {
|
|
97
|
+
const url = 'url' in config ? config.url : undefined;
|
|
98
|
+
return {
|
|
99
|
+
data: {
|
|
100
|
+
data: url === 'skillDefinitions:list' ? skillDefinitions : url === 'skillLoopConfigs:list' ? loopConfigs : [],
|
|
101
|
+
},
|
|
102
|
+
status: 200,
|
|
103
|
+
statusText: 'OK',
|
|
104
|
+
headers: {},
|
|
105
|
+
config: { headers: new AxiosHeaders() },
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
vi.spyOn(ClientV2, 'useApp').mockReturnValue(app);
|
|
109
|
+
|
|
110
|
+
const nativeEdit = vi.fn(async (_args: unknown) => {});
|
|
111
|
+
const genericEdit = vi.fn(async (_args: unknown) => {});
|
|
112
|
+
const registerTools = vi.fn();
|
|
113
|
+
|
|
114
|
+
await registerSkillLoopCards({
|
|
115
|
+
aiManager: { toolsManager: { registerTools } },
|
|
116
|
+
apiClient: app.apiClient,
|
|
117
|
+
});
|
|
118
|
+
expect(registerTools.mock.calls.map(([name]) => name)).toEqual([
|
|
119
|
+
'skill_hub_execute',
|
|
120
|
+
'skill_hub_original_identity',
|
|
121
|
+
'skill_hub_legacy_skill',
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
render(
|
|
125
|
+
<InteractionSchemasProvider>
|
|
126
|
+
<div data-testid="native-card">
|
|
127
|
+
<SkillHubCard
|
|
128
|
+
{...cardProps('skill_hub_original_identity', { retained: 'native', choice: 'old' }, nativeEdit)}
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
<div data-testid="generic-card">
|
|
132
|
+
<SkillHubCard
|
|
133
|
+
{...cardProps(
|
|
134
|
+
'skill_hub_execute',
|
|
135
|
+
{ action: 'execute', skillName: 'Renamed & Skill', input: { retained: 'generic', choice: 'old' } },
|
|
136
|
+
genericEdit,
|
|
137
|
+
)}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
<div data-testid="loop-b-card">
|
|
141
|
+
<SkillHubCard
|
|
142
|
+
{...cardProps(
|
|
143
|
+
'skill_hub_legacy_skill',
|
|
144
|
+
{},
|
|
145
|
+
vi.fn(async (_args: unknown) => {}),
|
|
146
|
+
)}
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
</InteractionSchemasProvider>,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
expect(request).toHaveBeenCalledWith(
|
|
153
|
+
expect.objectContaining({
|
|
154
|
+
url: 'skillDefinitions:list',
|
|
155
|
+
params: expect.objectContaining({ fields: expect.arrayContaining(['toolName', 'autoCall']) }),
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
await waitFor(() => expect(screen.getAllByRole('radio')).toHaveLength(6));
|
|
159
|
+
const nativeCardNode = screen.getByTestId('native-card');
|
|
160
|
+
const genericCardNode = screen.getByTestId('generic-card');
|
|
161
|
+
const loopBCardNode = screen.getByTestId('loop-b-card');
|
|
162
|
+
const nativeCard = within(nativeCardNode);
|
|
163
|
+
const genericCard = within(genericCardNode);
|
|
164
|
+
expect(nativeCardNode.textContent).toContain('Choose native input');
|
|
165
|
+
expect(genericCardNode.textContent).toContain('Choose native input');
|
|
166
|
+
|
|
167
|
+
fireEvent.click(nativeCard.getByRole('radio', { name: 'Native new' }));
|
|
168
|
+
fireEvent.click(genericCard.getByRole('radio', { name: 'Native new' }));
|
|
169
|
+
fireEvent.click(nativeCard.getByRole('button', { name: 'Run' }));
|
|
170
|
+
fireEvent.click(genericCard.getByRole('button', { name: 'Run' }));
|
|
171
|
+
|
|
172
|
+
await waitFor(() => {
|
|
173
|
+
expect(nativeEdit).toHaveBeenCalledWith({ retained: 'native', choice: 'new' });
|
|
174
|
+
expect(genericEdit).toHaveBeenCalledWith({
|
|
175
|
+
action: 'execute',
|
|
176
|
+
skillName: 'Renamed & Skill',
|
|
177
|
+
input: { retained: 'generic', choice: 'new' },
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
nativeEdit.mockClear();
|
|
182
|
+
genericEdit.mockClear();
|
|
183
|
+
loopConfigs = [
|
|
184
|
+
{
|
|
185
|
+
skillId: 1,
|
|
186
|
+
schema: {
|
|
187
|
+
type: 'select',
|
|
188
|
+
prompt: 'Updated A loop schema',
|
|
189
|
+
options: [{ label: 'A updated choice', value: 'a-updated' }],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{ skillId: 2, schema: { type: 'confirm', prompt: 'B2 loop schema' } },
|
|
193
|
+
{
|
|
194
|
+
skillId: 1,
|
|
195
|
+
schema: {
|
|
196
|
+
type: 'select',
|
|
197
|
+
prompt: 'Older A1 loop schema',
|
|
198
|
+
options: [{ label: 'A1 older choice', value: 'a1-older' }],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
act(() => {
|
|
203
|
+
window.dispatchEvent(new Event('skill-hub-loop-settings-changed'));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
await waitFor(() => {
|
|
207
|
+
expect(nativeCardNode.textContent).toContain('Updated A loop schema');
|
|
208
|
+
expect(nativeCardNode.textContent).not.toContain('Older A1 loop schema');
|
|
209
|
+
expect(loopBCardNode.textContent).toContain('B2 loop schema');
|
|
210
|
+
});
|
|
211
|
+
expect(request).toHaveBeenCalledWith(
|
|
212
|
+
expect.objectContaining({
|
|
213
|
+
url: 'skillLoopConfigs:list',
|
|
214
|
+
params: expect.objectContaining({ sort: ['-updatedAt'] }),
|
|
215
|
+
}),
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
fireEvent.click(nativeCard.getByRole('radio', { name: 'A updated choice' }));
|
|
219
|
+
fireEvent.click(genericCard.getByRole('radio', { name: 'A updated choice' }));
|
|
220
|
+
fireEvent.click(nativeCard.getByRole('button', { name: 'Run' }));
|
|
221
|
+
fireEvent.click(genericCard.getByRole('button', { name: 'Run' }));
|
|
222
|
+
await waitFor(() => {
|
|
223
|
+
expect(nativeEdit).toHaveBeenCalledWith({ retained: 'native', choice: 'a-updated' });
|
|
224
|
+
expect(genericEdit).toHaveBeenCalledWith({
|
|
225
|
+
action: 'execute',
|
|
226
|
+
skillName: 'Renamed & Skill',
|
|
227
|
+
input: { retained: 'generic', choice: 'a-updated' },
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
loopConfigs = [
|
|
232
|
+
{ skillId: 1, schema: '{broken' },
|
|
233
|
+
{ skillId: 2, schema: { type: 'confirm', prompt: 'B2 loop schema' } },
|
|
234
|
+
{
|
|
235
|
+
skillId: 1,
|
|
236
|
+
schema: {
|
|
237
|
+
type: 'select',
|
|
238
|
+
prompt: 'Older A1 loop schema',
|
|
239
|
+
options: [{ label: 'A1 older choice', value: 'a1-older' }],
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
];
|
|
243
|
+
act(() => {
|
|
244
|
+
window.dispatchEvent(new Event('skill-hub-loop-settings-changed'));
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
await waitFor(() => {
|
|
248
|
+
expect(nativeCardNode.textContent).toContain('Choose native input');
|
|
249
|
+
expect(nativeCardNode.textContent).not.toContain('Older A1 loop schema');
|
|
250
|
+
expect(genericCardNode.textContent).toContain('Choose native input');
|
|
251
|
+
expect(loopBCardNode.textContent).toContain('B2 loop schema');
|
|
252
|
+
});
|
|
253
|
+
expect(nativeCard.getByRole('radio', { name: 'Native old' })).toBeTruthy();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
@@ -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 { SkillHubCard } from './SkillHubCard';
|
|
2
11
|
import { parseJsonText } from '../utils/jsonFields';
|
|
3
12
|
|
|
@@ -37,7 +46,7 @@ export async function registerSkillLoopCards(app: any) {
|
|
|
37
46
|
skipNotify: true,
|
|
38
47
|
params: {
|
|
39
48
|
filter: { enabled: true },
|
|
40
|
-
fields: ['id', 'name', 'autoCall', 'interactionSchema'],
|
|
49
|
+
fields: ['id', 'name', 'toolName', 'autoCall', 'interactionSchema'],
|
|
41
50
|
pageSize: 500,
|
|
42
51
|
},
|
|
43
52
|
});
|
|
@@ -61,9 +70,9 @@ export async function registerSkillLoopCards(app: any) {
|
|
|
61
70
|
const skills = extractList(skillsResponse.data);
|
|
62
71
|
for (const skill of skills) {
|
|
63
72
|
const hasLoopConfig = loopSkillIds.has(String(skill.id));
|
|
64
|
-
const hasLegacySchema =
|
|
73
|
+
const hasLegacySchema = !!parseJsonText(skill.interactionSchema, null);
|
|
65
74
|
if (!hasLoopConfig && !hasLegacySchema) continue;
|
|
66
|
-
registerSkillHubCard(toolsManager, `skill_hub_${sanitize(skill.name)}`);
|
|
75
|
+
registerSkillHubCard(toolsManager, skill.toolName?.trim() || `skill_hub_${sanitize(skill.name)}`);
|
|
67
76
|
}
|
|
68
77
|
} catch {
|
|
69
78
|
// user without ACL or backend unavailable - skip silently
|
|
@@ -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 { cleanup, render, screen, waitFor } from '@testing-library/react';
|
|
@@ -89,8 +82,8 @@ function mockApiRequest(app: ReturnType<typeof ClientV2.createMockClient>) {
|
|
|
89
82
|
data:
|
|
90
83
|
url === 'agentHarnessProfiles:capabilities'
|
|
91
84
|
? { data: emptyCapabilityMatrix }
|
|
92
|
-
: url === '
|
|
93
|
-
? { data: [{
|
|
85
|
+
: url === 'embedSettings:enabled'
|
|
86
|
+
? { data: [{ pluginName: 'ai-orchestrator', title: 'Agent Orchestrator' }] }
|
|
94
87
|
: { data: [], meta: { count: 0 } },
|
|
95
88
|
status: 200,
|
|
96
89
|
statusText: 'OK',
|
|
@@ -100,6 +93,20 @@ function mockApiRequest(app: ReturnType<typeof ClientV2.createMockClient>) {
|
|
|
100
93
|
});
|
|
101
94
|
}
|
|
102
95
|
|
|
96
|
+
function renderWithAcl(node: React.ReactNode) {
|
|
97
|
+
return render(
|
|
98
|
+
<ClientV2.ACLContext.Provider
|
|
99
|
+
value={{
|
|
100
|
+
loading: false,
|
|
101
|
+
data: { data: { role: 'admin', snippets: ['pm.*'] }, meta: {} },
|
|
102
|
+
refresh: async () => {},
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
{node}
|
|
106
|
+
</ClientV2.ACLContext.Provider>,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
beforeEach(() => {
|
|
104
111
|
vi.spyOn(window, 'matchMedia').mockImplementation((media) => ({
|
|
105
112
|
matches: false,
|
|
@@ -132,6 +139,8 @@ describe('Agent Orchestrator v2 embedded settings', () => {
|
|
|
132
139
|
async function loadPlugin() {
|
|
133
140
|
const app = ClientV2.createMockClient();
|
|
134
141
|
await new PluginAgentOrchestratorClient({}, app).load();
|
|
142
|
+
app.context.acl.setData({ role: 'admin', snippets: ['pm.*'] });
|
|
143
|
+
app.pluginSettingsManager.setAclSnippets(['pm.*']);
|
|
135
144
|
return app;
|
|
136
145
|
}
|
|
137
146
|
|
|
@@ -181,7 +190,7 @@ describe('Agent Orchestrator v2 embedded settings', () => {
|
|
|
181
190
|
const request = mockApiRequest(app);
|
|
182
191
|
vi.spyOn(ClientV2, 'useApp').mockReturnValue(app);
|
|
183
192
|
|
|
184
|
-
const view =
|
|
193
|
+
const view = renderWithAcl(
|
|
185
194
|
<EmbedSettingsBlock pluginName="ai-orchestrator" enabledTabKeys={['ai-orchestrator.employee-governance']} />,
|
|
186
195
|
);
|
|
187
196
|
|