plugin-agent-orchestrator 1.0.16 → 1.0.17

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.
Files changed (56) hide show
  1. package/dist/externalVersion.js +6 -6
  2. package/dist/server/tools/delegate-task.js +38 -2
  3. package/package.json +2 -2
  4. package/src/server/tools/delegate-task.ts +52 -5
  5. package/dist/client/AIEmployeeSelect.d.ts +0 -11
  6. package/dist/client/AIEmployeesContext.d.ts +0 -30
  7. package/dist/client/OrchestratorSettings.d.ts +0 -3
  8. package/dist/client/RulesTab.d.ts +0 -2
  9. package/dist/client/TracingTab.d.ts +0 -2
  10. package/dist/client/index.d.ts +0 -1
  11. package/dist/client/plugin.d.ts +0 -6
  12. package/dist/client/skill-hub/components/ExecutionHistory.d.ts +0 -2
  13. package/dist/client/skill-hub/components/ExecutionProgress.d.ts +0 -20
  14. package/dist/client/skill-hub/components/GitSkillImport.d.ts +0 -7
  15. package/dist/client/skill-hub/components/SkillEditor.d.ts +0 -7
  16. package/dist/client/skill-hub/components/SkillManager.d.ts +0 -2
  17. package/dist/client/skill-hub/components/SkillMetrics.d.ts +0 -2
  18. package/dist/client/skill-hub/components/SkillTestPanel.d.ts +0 -7
  19. package/dist/client/skill-hub/index.d.ts +0 -10
  20. package/dist/client/skill-hub/locale.d.ts +0 -3
  21. package/dist/client/skill-hub/tools/InteractionSchemasProvider.d.ts +0 -19
  22. package/dist/client/skill-hub/tools/SkillHubCard.d.ts +0 -3
  23. package/dist/client/skill-hub/utils/jsonFields.d.ts +0 -3
  24. package/dist/index.d.ts +0 -2
  25. package/dist/server/collections/agent-execution-spans.d.ts +0 -9
  26. package/dist/server/collections/orchestrator-config.d.ts +0 -2
  27. package/dist/server/collections/orchestrator-logs.d.ts +0 -8
  28. package/dist/server/collections/skill-definitions.d.ts +0 -3
  29. package/dist/server/collections/skill-executions.d.ts +0 -3
  30. package/dist/server/collections/skill-worker-configs.d.ts +0 -3
  31. package/dist/server/index.d.ts +0 -1
  32. package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +0 -4
  33. package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +0 -4
  34. package/dist/server/migrations/20260427000000-add-tracing-detail-fields.d.ts +0 -7
  35. package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +0 -4
  36. package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +0 -4
  37. package/dist/server/migrations/20260429000000-add-llm-fields.d.ts +0 -7
  38. package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +0 -16
  39. package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +0 -7
  40. package/dist/server/plugin.d.ts +0 -14
  41. package/dist/server/resources/tracing.d.ts +0 -7
  42. package/dist/server/services/CodeValidator.d.ts +0 -32
  43. package/dist/server/services/ExecutionSpanService.d.ts +0 -44
  44. package/dist/server/services/FileManager.d.ts +0 -28
  45. package/dist/server/services/SandboxRunner.d.ts +0 -41
  46. package/dist/server/services/SkillManager.d.ts +0 -6
  47. package/dist/server/services/SkillRepositoryService.d.ts +0 -22
  48. package/dist/server/services/WorkerEnvManager.d.ts +0 -26
  49. package/dist/server/skill-hub/actions/git-import.d.ts +0 -21
  50. package/dist/server/skill-hub/mcp/McpController.d.ts +0 -15
  51. package/dist/server/skill-hub/plugin.d.ts +0 -58
  52. package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +0 -16
  53. package/dist/server/skill-hub/utils/json-fields.d.ts +0 -7
  54. package/dist/server/tools/delegate-task.d.ts +0 -19
  55. package/dist/server/tools/external-rag-search.d.ts +0 -42
  56. package/dist/server/tools/skill-execute.d.ts +0 -36
@@ -9,14 +9,14 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "2.0.49",
12
+ "@nocobase/client": "2.0.55",
13
13
  "antd": "5.24.2",
14
14
  "@ant-design/icons": "5.6.1",
15
- "@nocobase/server": "2.0.49",
16
- "@nocobase/database": "2.0.49",
17
- "@nocobase/actions": "2.0.49",
15
+ "@nocobase/server": "2.0.55",
16
+ "@nocobase/database": "2.0.55",
17
+ "@nocobase/actions": "2.0.55",
18
18
  "@langchain/langgraph": "0.2.74",
19
19
  "@langchain/core": "0.3.80",
20
- "@nocobase/plugin-ai": "2.0.49",
21
- "@nocobase/ai": "2.0.49"
20
+ "@nocobase/plugin-ai": "2.0.55",
21
+ "@nocobase/ai": "2.0.55"
22
22
  };
@@ -37,6 +37,7 @@ var import_tools = require("@langchain/core/tools");
37
37
  var import_messages = require("@langchain/core/messages");
38
38
  var import_ExecutionSpanService = require("../services/ExecutionSpanService");
39
39
  const ORCHESTRATOR_DEPTH_KEY = "__orchestratorDepth";
40
+ const ORCHESTRATOR_PATH_KEY = "__orchestratorPath";
40
41
  const MAX_DISPATCH_CONCURRENCY = 5;
41
42
  const MAX_DISPATCH_TASKS = 20;
42
43
  const MAX_TOOL_NAME_LENGTH = 64;
@@ -573,6 +574,27 @@ async function invokeDelegateTask(ctx, plugin, options) {
573
574
  } = options;
574
575
  const ctxSnapshot = captureCtxSnapshot(ctx);
575
576
  const currentDepth = ctx[ORCHESTRATOR_DEPTH_KEY] ?? 0;
577
+ const currentPath = ctx[ORCHESTRATOR_PATH_KEY] ?? [leaderUsername];
578
+ if (currentPath.includes(subAgentUsername)) {
579
+ const loopChain = [...currentPath, subAgentUsername].join(" -> ");
580
+ await logDelegation(ctx, plugin, {
581
+ leaderUsername,
582
+ subAgentUsername,
583
+ toolName,
584
+ task,
585
+ context,
586
+ result: "",
587
+ status: "error",
588
+ depth: currentDepth,
589
+ durationMs: 0,
590
+ error: `Circular delegation detected: ${loopChain}.`,
591
+ snapshot: ctxSnapshot
592
+ });
593
+ return {
594
+ status: "error",
595
+ content: `Circular delegation detected: ${loopChain}. Execution aborted to prevent infinite reasoning loops.`
596
+ };
597
+ }
576
598
  if (currentDepth >= maxDepth) {
577
599
  await logDelegation(ctx, plugin, {
578
600
  leaderUsername,
@@ -677,7 +699,7 @@ async function invokeDelegateTask(ctx, plugin, options) {
677
699
  const entryName = toolEntry.definition.name;
678
700
  if (!entryName) continue;
679
701
  const employeeSkill = employeeSkillMap.get(entryName);
680
- if (!employeeSkill || isDelegateToolName(plugin, entryName) || employeeSkill.autoCall !== true || toolEntry.defaultPermission !== "ALLOW") {
702
+ if (!employeeSkill || isDelegateToolName(plugin, entryName) || employeeSkill.autoCall !== true) {
681
703
  continue;
682
704
  }
683
705
  langchainTools.push(
@@ -689,6 +711,12 @@ async function invokeDelegateTask(ctx, plugin, options) {
689
711
  var _a2;
690
712
  const invokeCtx = Object.create(ctx);
691
713
  invokeCtx[ORCHESTRATOR_DEPTH_KEY] = currentDepth + 1;
714
+ invokeCtx[ORCHESTRATOR_PATH_KEY] = [...currentPath, subAgentUsername];
715
+ invokeCtx._currentAIEmployee = subAgentUsername;
716
+ if (ctx.state) {
717
+ invokeCtx.state = Object.create(ctx.state);
718
+ invokeCtx.state.currentAIEmployee = subAgentUsername;
719
+ }
692
720
  const toolStartedAt = Date.now();
693
721
  const isSkillHubTool = entryName === "skill_hub_execute" || entryName.startsWith("skill_hub_");
694
722
  const toolSpan = await spanService.create({
@@ -887,9 +915,17 @@ ${context}` : `Task: ${task}`;
887
915
  traceCount: trace.length + 1
888
916
  }
889
917
  });
918
+ const diagnosticTrace = trace.filter((t) => t.type === "tool_error" || t.type === "error").map((t) => `[${t.toolName ? `Tool: ${t.toolName}` : "Sub-agent"}] Error: ${t.content || t.title}`).join("\n");
919
+ const formattedError = [
920
+ `Sub-agent "${subAgentUsername}" failed execution: ${e.message}`,
921
+ diagnosticTrace ? `
922
+ Diagnostic Details of internal failures:
923
+ ${diagnosticTrace}` : "",
924
+ `Suggestion: Review the tool parameters above or try dividing the task into simpler independent tasks.`
925
+ ].filter(Boolean).join("\n");
890
926
  return {
891
927
  status: "error",
892
- content: `Sub-agent "${subAgentUsername}" failed: ${e.message}`
928
+ content: formattedError
893
929
  };
894
930
  }
895
931
  }
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": "Hierarchical Multi-Agent orchestration for NocoBase AI Employees. Enables Leader agents to delegate tasks to Sub-Agent employees without modifying core plugin-ai.",
7
- "version": "1.0.16",
7
+ "version": "1.0.17",
8
8
  "license": "Apache-2.0",
9
9
  "main": "dist/server/index.js",
10
10
  "keywords": [
@@ -42,4 +42,4 @@
42
42
  "@nocobase/ai": "2.x",
43
43
  "@nocobase/plugin-ai": "2.x"
44
44
  }
45
- }
45
+ }
@@ -18,6 +18,12 @@ import {
18
18
  * Used to prevent circular/recursive delegation chains.
19
19
  */
20
20
  const ORCHESTRATOR_DEPTH_KEY = '__orchestratorDepth';
21
+ /**
22
+ * Context key for tracking the full delegation path.
23
+ * Used to detect and prevent circular delegation chains.
24
+ */
25
+ const ORCHESTRATOR_PATH_KEY = '__orchestratorPath';
26
+
21
27
 
22
28
  /** Max sub-agents that the dispatch tool runs concurrently in one call. */
23
29
  const MAX_DISPATCH_CONCURRENCY = 5;
@@ -794,8 +800,31 @@ async function invokeDelegateTask(
794
800
  // Capturing the values once here keeps log/audit fields stable.
795
801
  const ctxSnapshot = captureCtxSnapshot(ctx);
796
802
 
797
- // --- P1: Depth enforcement ---
803
+ // --- P1: Depth enforcement & Circular Delegation Detection ---
798
804
  const currentDepth: number = (ctx as any)[ORCHESTRATOR_DEPTH_KEY] ?? 0;
805
+ const currentPath: string[] = (ctx as any)[ORCHESTRATOR_PATH_KEY] ?? [leaderUsername];
806
+
807
+ if (currentPath.includes(subAgentUsername)) {
808
+ const loopChain = [...currentPath, subAgentUsername].join(' -> ');
809
+ await logDelegation(ctx, plugin, {
810
+ leaderUsername,
811
+ subAgentUsername,
812
+ toolName,
813
+ task,
814
+ context,
815
+ result: '',
816
+ status: 'error',
817
+ depth: currentDepth,
818
+ durationMs: 0,
819
+ error: `Circular delegation detected: ${loopChain}.`,
820
+ snapshot: ctxSnapshot,
821
+ });
822
+ return {
823
+ status: 'error' as const,
824
+ content: `Circular delegation detected: ${loopChain}. Execution aborted to prevent infinite reasoning loops.`,
825
+ };
826
+ }
827
+
799
828
  if (currentDepth >= maxDepth) {
800
829
  await logDelegation(ctx, plugin, {
801
830
  leaderUsername,
@@ -943,8 +972,7 @@ async function invokeDelegateTask(
943
972
  if (
944
973
  !employeeSkill ||
945
974
  isDelegateToolName(plugin, entryName) ||
946
- employeeSkill.autoCall !== true ||
947
- toolEntry.defaultPermission !== 'ALLOW'
975
+ employeeSkill.autoCall !== true
948
976
  ) {
949
977
  continue;
950
978
  }
@@ -955,9 +983,15 @@ async function invokeDelegateTask(
955
983
  description: toolEntry.definition.description || entryName,
956
984
  schema: (toolEntry.definition.schema || z.object({})) as any,
957
985
  func: async (toolArgs) => {
958
- // Forward the invoke with depth tracking
986
+ // Forward the invoke with depth tracking, circular path tracking and identity overrides
959
987
  const invokeCtx = Object.create(ctx);
960
988
  (invokeCtx as any)[ORCHESTRATOR_DEPTH_KEY] = currentDepth + 1;
989
+ (invokeCtx as any)[ORCHESTRATOR_PATH_KEY] = [...currentPath, subAgentUsername];
990
+ (invokeCtx as any)._currentAIEmployee = subAgentUsername;
991
+ if (ctx.state) {
992
+ invokeCtx.state = Object.create(ctx.state);
993
+ invokeCtx.state.currentAIEmployee = subAgentUsername;
994
+ }
961
995
  const toolStartedAt = Date.now();
962
996
  const isSkillHubTool = entryName === 'skill_hub_execute' || entryName.startsWith('skill_hub_');
963
997
  const toolSpan = await spanService.create({
@@ -1183,9 +1217,22 @@ async function invokeDelegateTask(
1183
1217
  },
1184
1218
  });
1185
1219
 
1220
+ const diagnosticTrace = trace
1221
+ .filter((t) => t.type === 'tool_error' || t.type === 'error')
1222
+ .map((t) => `[${t.toolName ? `Tool: ${t.toolName}` : 'Sub-agent'}] Error: ${t.content || t.title}`)
1223
+ .join('\n');
1224
+
1225
+ const formattedError = [
1226
+ `Sub-agent "${subAgentUsername}" failed execution: ${e.message}`,
1227
+ diagnosticTrace ? `\nDiagnostic Details of internal failures:\n${diagnosticTrace}` : '',
1228
+ `Suggestion: Review the tool parameters above or try dividing the task into simpler independent tasks.`,
1229
+ ]
1230
+ .filter(Boolean)
1231
+ .join('\n');
1232
+
1186
1233
  return {
1187
1234
  status: 'error' as const,
1188
- content: `Sub-agent "${subAgentUsername}" failed: ${e.message}`,
1235
+ content: formattedError,
1189
1236
  };
1190
1237
  }
1191
1238
  }
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Reusable Select component for AI Employees.
4
- * P3 FIX: Uses shared AIEmployeesContext instead of making its own API call.
5
- */
6
- export declare const AIEmployeeSelect: React.FC<{
7
- value?: string;
8
- onChange?: (value: string) => void;
9
- exclude?: string;
10
- placeholder?: string;
11
- }>;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- interface AIEmployeeInfo {
3
- username: string;
4
- nickname: string;
5
- about?: string;
6
- skills: string[];
7
- }
8
- interface AIEmployeesContextType {
9
- employees: AIEmployeeInfo[];
10
- employeeMap: Map<string, string>;
11
- skillsMap: Map<string, Set<string>>;
12
- loading: boolean;
13
- refresh: () => void;
14
- }
15
- /**
16
- * P3 FIX: Shared context provider that fetches aiEmployees once
17
- * and shares the data across RulesTab, TracingTab, and AIEmployeeSelect.
18
- *
19
- * Also exposes each employee's configured skills so RulesTab can warn when
20
- * a delegation rule exists but the leader hasn't added the corresponding
21
- * delegate_<leader>_to_<sub> tool to its skillSettings.
22
- */
23
- export declare const AIEmployeesProvider: React.FC<{
24
- children: React.ReactNode;
25
- }>;
26
- /**
27
- * Hook to access shared AI employees data.
28
- */
29
- export declare const useAIEmployees: () => AIEmployeesContextType;
30
- export {};
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const OrchestratorSettings: React.FC;
3
- export { OrchestratorSettings };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const RulesTab: React.FC;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const TracingTab: React.FC;
@@ -1 +0,0 @@
1
- export { default } from './plugin';
@@ -1,6 +0,0 @@
1
- import { Plugin } from '@nocobase/client';
2
- export declare class PluginAgentOrchestratorClient extends Plugin {
3
- load(): Promise<void>;
4
- private registerSkillUiCards;
5
- }
6
- export default PluginAgentOrchestratorClient;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ExecutionHistory: React.FC;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- interface ExecutionProgressProps {
3
- execId: string;
4
- skillName: string;
5
- percent: number;
6
- log: string;
7
- }
8
- /**
9
- * Progress component rendered inside chat UI when receiving
10
- * SSE custom event: {action: "skillProgress", body: {...}}
11
- *
12
- * Usage in chat message renderer:
13
- * ```
14
- * if (event.action === 'skillProgress') {
15
- * return <ExecutionProgress {...event.body} />;
16
- * }
17
- * ```
18
- */
19
- export declare const ExecutionProgress: React.FC<ExecutionProgressProps>;
20
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface GitSkillImportProps {
3
- open: boolean;
4
- onClose: (synced?: boolean) => void;
5
- }
6
- export declare const GitSkillImport: React.FC<GitSkillImportProps>;
7
- export {};
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface SkillEditorProps {
3
- skill: any | null;
4
- onClose: (saved?: boolean) => void;
5
- }
6
- export declare const SkillEditor: React.FC<SkillEditorProps>;
7
- export {};
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const SkillManager: React.FC;
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const SkillMetrics: React.FC;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface SkillTestPanelProps {
3
- skill: any;
4
- onClose: () => void;
5
- }
6
- export declare const SkillTestPanel: React.FC<SkillTestPanelProps>;
7
- export {};
@@ -1,10 +0,0 @@
1
- import { Plugin } from '@nocobase/client';
2
- import { SkillManager } from './components/SkillManager';
3
- import { ExecutionHistory } from './components/ExecutionHistory';
4
- import { SkillMetrics } from './components/SkillMetrics';
5
- export declare class PluginSkillHubClient extends Plugin {
6
- load(): Promise<void>;
7
- private registerSkillUiCards;
8
- }
9
- export { SkillManager, ExecutionHistory, SkillMetrics };
10
- export default PluginSkillHubClient;
@@ -1,3 +0,0 @@
1
- export declare const namespace = "plugin-agent-orchestrator";
2
- export declare function useT(): (str: string, options?: any) => string;
3
- export declare function tStr(key: string): string;
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- export type InteractionSchema = {
3
- type: 'form' | 'select' | 'confirm';
4
- prompt: string;
5
- options?: {
6
- label: string;
7
- value: string | number;
8
- }[];
9
- fields?: Record<string, {
10
- type?: string;
11
- title?: string;
12
- required?: boolean;
13
- enum?: any[];
14
- }>;
15
- };
16
- export declare const useInteractionSchemas: () => Map<string, InteractionSchema>;
17
- export declare const InteractionSchemasProvider: React.FC<{
18
- children?: React.ReactNode;
19
- }>;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import { ToolsUIProperties } from '@nocobase/client';
3
- export declare const SkillHubCard: React.FC<ToolsUIProperties>;
@@ -1,3 +0,0 @@
1
- export declare function parseJsonText<T = any>(value: any, fallback: T): T;
2
- export declare function formatJsonText(value: any, fallback?: any): string;
3
- export declare function stringifyJsonText(value: any, fallback?: any): string;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './server';
2
- export { default } from './server';
@@ -1,9 +0,0 @@
1
- /**
2
- * Unified execution graph for agent orchestration.
3
- *
4
- * A root run can contain sub-agent spans and child tool/skill spans. Skill Hub
5
- * keeps its own sandbox execution records; this collection stores the flow
6
- * relationship and links to those records when applicable.
7
- */
8
- declare const _default: import("@nocobase/database").CollectionOptions;
9
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: import("@nocobase/database").CollectionOptions;
2
- export default _default;
@@ -1,8 +0,0 @@
1
- /**
2
- * Stores delegation execution logs for Swarm Tracing (Phase 5).
3
- *
4
- * Since createReactAgent doesn't create aiConversation records,
5
- * we log delegation events to a dedicated table for observability.
6
- */
7
- declare const _default: import("@nocobase/database").CollectionOptions;
8
- export default _default;
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import { CollectionOptions } from '@nocobase/database';
2
- declare const _default: CollectionOptions;
3
- export default _default;
@@ -1 +0,0 @@
1
- export { default } from './plugin';
@@ -1,4 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class AddProgressFieldsMigration extends Migration {
3
- up(): Promise<void>;
4
- }
@@ -1,4 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class AddInteractionSchemaMigration extends Migration {
3
- up(): Promise<void>;
4
- }
@@ -1,7 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class AddTracingDetailFieldsMigration extends Migration {
3
- on: string;
4
- appVersion: string;
5
- up(): Promise<void>;
6
- down(): Promise<void>;
7
- }
@@ -1,4 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class ChangePackagesToTextMigration extends Migration {
3
- up(): Promise<void>;
4
- }
@@ -1,4 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class ChangeOtherJsonToTextMigration extends Migration {
3
- up(): Promise<void>;
4
- }
@@ -1,7 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class AddLlmFieldsToOrchestratorConfig extends Migration {
3
- on: string;
4
- appVersion: string;
5
- up(): Promise<void>;
6
- down(): Promise<void>;
7
- }
@@ -1,16 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- /**
3
- * Fix: inputArgs column in skillExecutions was json type but should be text.
4
- *
5
- * Root cause: The column was created as `json` from an older schema version,
6
- * but the collection defines it as `text`. The `stringifyJsonText()` utility
7
- * wraps values in markdown code fences (```json\n...\n```) which PostgreSQL
8
- * rejects as invalid JSON syntax, causing SequelizeDatabaseError on every
9
- * skill execution attempt.
10
- */
11
- export default class FixInputArgsJsonToText extends Migration {
12
- on: string;
13
- appVersion: string;
14
- up(): Promise<void>;
15
- down(): Promise<void>;
16
- }
@@ -1,7 +0,0 @@
1
- import { Migration } from '@nocobase/server';
2
- export default class AddOrchestratorTraceFieldsToSkillExecutions extends Migration {
3
- on: string;
4
- appVersion: string;
5
- up(): Promise<void>;
6
- down(): Promise<void>;
7
- }
@@ -1,14 +0,0 @@
1
- import { Plugin } from '@nocobase/server';
2
- import SkillHubSubFeature from './skill-hub/plugin';
3
- export declare class PluginAgentOrchestratorServer extends Plugin {
4
- skillHub: SkillHubSubFeature;
5
- afterAdd(): Promise<void>;
6
- beforeLoad(): Promise<void>;
7
- load(): Promise<void>;
8
- install(): Promise<void>;
9
- afterEnable(): Promise<void>;
10
- afterDisable(): Promise<void>;
11
- remove(): Promise<void>;
12
- beforeStop(): Promise<void>;
13
- }
14
- export default PluginAgentOrchestratorServer;
@@ -1,7 +0,0 @@
1
- import { Plugin } from '@nocobase/server';
2
- /**
3
- * Custom resource for the Swarm Tracing admin UI (Phase 5).
4
- * Queries the dedicated orchestratorLogs collection instead of
5
- * filtering aiConversations by JSONB (P2 fix: DB-engine agnostic).
6
- */
7
- export declare function registerTracingResource(plugin: Plugin): void;
@@ -1,32 +0,0 @@
1
- export declare class CodeValidator {
2
- /**
3
- * Check code against forbidden patterns (dangerous modules/functions).
4
- * @throws CodeValidationError if a forbidden pattern is found.
5
- */
6
- validate(code: string, language: 'node' | 'python'): void;
7
- /**
8
- * Validate that code only imports packages in the whitelist.
9
- * Called after the basic forbidden pattern check.
10
- * Skips validation if whitelist is empty (env not initialized yet).
11
- *
12
- * @param code - The code to validate
13
- * @param language - 'node' or 'python'
14
- * @param whitelist - Array of allowed package names (from skillWorkerConfigs.packageWhitelist)
15
- */
16
- validateImports(code: string, language: 'node' | 'python', whitelist: string[]): void;
17
- /**
18
- * Check Node.js require() calls against the whitelist.
19
- * Built-in modules (fs, path, etc.) are always allowed.
20
- */
21
- private validateNodeImports;
22
- /**
23
- * Check Python import/from statements against the whitelist.
24
- * Built-in modules (os, sys, json, etc.) are always allowed.
25
- * Handles PyPI→import name mapping (e.g., python-docx → docx, Pillow → PIL).
26
- */
27
- private validatePythonImports;
28
- }
29
- export declare class CodeValidationError extends Error {
30
- matchedPattern: string;
31
- constructor(message: string, matchedPattern: string);
32
- }
@@ -1,44 +0,0 @@
1
- export declare const ORCHESTRATOR_TRACE_CONTEXT_KEY = "__orchestratorTraceContext";
2
- export type OrchestratorTraceContext = {
3
- rootRunId: string;
4
- spanId?: string;
5
- parentSpanId?: string;
6
- toolCallId?: string;
7
- leaderUsername?: string;
8
- employeeUsername?: string;
9
- toolName?: string;
10
- };
11
- type SpanValues = {
12
- rootRunId: string;
13
- parentSpanId?: string;
14
- type: string;
15
- status: string;
16
- leaderUsername?: string;
17
- employeeUsername?: string;
18
- toolName?: string;
19
- title?: string;
20
- input?: any;
21
- output?: string;
22
- error?: string;
23
- durationMs?: number;
24
- startedAt?: Date;
25
- endedAt?: Date;
26
- orchestratorLogId?: string | number;
27
- skillExecutionId?: string | number;
28
- metadata?: any;
29
- userId?: string | number;
30
- };
31
- export declare class ExecutionSpanService {
32
- private readonly plugin;
33
- constructor(plugin: any);
34
- create(values: SpanValues): Promise<any>;
35
- update(spanId: string | number | undefined, values: Record<string, any>): Promise<{
36
- id: string | number;
37
- }>;
38
- finish(spanId: string | number | undefined, status: 'success' | 'error' | 'canceled' | 'timeout', startedAt: number, values?: Record<string, any>): Promise<{
39
- id: string | number;
40
- }>;
41
- }
42
- export declare function getOrchestratorTraceContext(ctx: any): OrchestratorTraceContext | null;
43
- export declare function setOrchestratorTraceContext(ctx: any, traceContext: OrchestratorTraceContext): any;
44
- export {};
@@ -1,28 +0,0 @@
1
- export interface OutputFileInfo {
2
- name: string;
3
- size: number;
4
- mimeType: string;
5
- }
6
- export declare class FileManager {
7
- private storagePath;
8
- private executionsDir;
9
- constructor(storagePath: string);
10
- createExecDir(execId: string): string;
11
- getExecDir(execId: string): string;
12
- getOutputDir(execId: string): string;
13
- /**
14
- * Returns absolute path to an output file, or null if invalid/not found.
15
- * Includes path traversal protection.
16
- */
17
- getOutputFilePath(execId: string, filename: string): string | null;
18
- listOutputFiles(execId: string): OutputFileInfo[];
19
- getTotalOutputSize(execId: string): number;
20
- /**
21
- * Remove a specific execution directory by execId.
22
- */
23
- removeExecDir(execId: string): void;
24
- /**
25
- * Remove execution directories older than maxAgeMs.
26
- */
27
- cleanupOlderThan(maxAgeMs: number): number;
28
- }
@@ -1,41 +0,0 @@
1
- import { FileManager, OutputFileInfo } from './FileManager';
2
- export interface ExecuteOptions {
3
- language: 'node' | 'python';
4
- code: string;
5
- execId: string;
6
- timeoutSeconds?: number;
7
- maxOutputSizeMb?: number;
8
- onProgress?: (progress: ProgressUpdate) => void;
9
- /** AbortSignal — when aborted, the child process is killed */
10
- signal?: {
11
- addEventListener(event: string, listener: () => void): void;
12
- };
13
- /** Package whitelist for import validation (from skillWorkerConfigs) */
14
- packageWhitelist?: string[];
15
- /** Optional installed/copied skill package root exposed to the runtime as SKILL_DIR. */
16
- skillDir?: string;
17
- }
18
- export interface ProgressUpdate {
19
- percent: number;
20
- log: string;
21
- }
22
- export interface ExecutionResult {
23
- success: boolean;
24
- stdout: string;
25
- stderr: string;
26
- files: OutputFileInfo[];
27
- durationMs: number;
28
- /** true if execution was canceled by user */
29
- canceled?: boolean;
30
- /** true if execution timed out */
31
- timedOut?: boolean;
32
- }
33
- export declare class SandboxRunner {
34
- private fileManager;
35
- private logger;
36
- private storagePath;
37
- private validator;
38
- private sandboxWorkspace;
39
- constructor(fileManager: FileManager, logger: any, storagePath: string);
40
- execute(options: ExecuteOptions): Promise<ExecutionResult>;
41
- }
@@ -1,6 +0,0 @@
1
- import { Database } from '@nocobase/database';
2
- export declare class SkillManager {
3
- private db;
4
- constructor(db: Database);
5
- seedDefaults(): Promise<void>;
6
- }
@@ -1,22 +0,0 @@
1
- export interface SkillPackageMetadata {
2
- path: string;
3
- metadata: Record<string, any>;
4
- instructions: string;
5
- code: string | null;
6
- }
7
- export declare class SkillRepositoryService {
8
- private baseDir;
9
- constructor(storagePath: string);
10
- /**
11
- * Extract a zip file to the repository.
12
- * Returns parsed metadata from SKILL.md / skill.yaml
13
- */
14
- extractSkillPackage(skillName: string, zipFilePath: string): Promise<SkillPackageMetadata>;
15
- getSkillPath(skillName: string): string;
16
- getSkillCode(skillName: string): string | null;
17
- copySkillPackageTo(skillName: string, destDir: string): void;
18
- readSkillPackage(packageDir: string): SkillPackageMetadata;
19
- copyDirectoryTo(srcDir: string, destDir: string): void;
20
- private getSkillCodeFromDir;
21
- private aggregateOtherMarkdownFiles;
22
- }
@@ -1,26 +0,0 @@
1
- import Application from '@nocobase/server';
2
- import { Database } from '@nocobase/database';
3
- type WorkerEnvConfig = {
4
- npmRegistryUrl?: string;
5
- npmAuthToken?: string;
6
- pypiIndexUrl?: string;
7
- pypiTrustedHost?: string;
8
- aptMirrorUrl?: string;
9
- aptGpgKeyUrl?: string;
10
- customPackages?: {
11
- python?: string[];
12
- node?: string[];
13
- apt?: string[];
14
- };
15
- };
16
- export declare class WorkerEnvManager {
17
- private readonly app;
18
- private readonly db;
19
- private readonly storagePath;
20
- constructor(app: Application, db: Database, storagePath: string);
21
- getOrCreateConfig(): Promise<any>;
22
- initEnvironment(config: WorkerEnvConfig): Promise<string>;
23
- executeInit(payload: WorkerEnvConfig): Promise<void>;
24
- parsePackageWhitelist(config: any): Record<"node" | "python" | "apt", string[]>;
25
- }
26
- export {};
@@ -1,21 +0,0 @@
1
- import { Context } from '@nocobase/actions';
2
- /**
3
- * Git integration actions for skill-hub.
4
- *
5
- * Supported manifest shape:
6
- * {
7
- * "skills": [
8
- * { "folder": "my-skill", "name": "my-skill", "language": "python" },
9
- * { "name": "pptx-advanced-export", "storageType": "plugin", "pluginSource": "pptx-advanced-export" }
10
- * ]
11
- * }
12
- */
13
- export declare function gitListSkills(ctx: Context, next: () => Promise<void>): Promise<void>;
14
- /**
15
- * Sync selected skills from git into skillDefinitions.
16
- *
17
- * Code is optional. Regular git skills may provide code via codeTemplate,
18
- * codeFile, or conventional files under skills/<folder>. Plugin skills only
19
- * need storageType=plugin and pluginSource.
20
- */
21
- export declare function gitSyncSkills(ctx: Context, next: () => Promise<void>): Promise<void>;
@@ -1,15 +0,0 @@
1
- import type PluginSkillHubServer from '../plugin';
2
- export declare class McpController {
3
- private plugin;
4
- constructor(plugin: PluginSkillHubServer);
5
- /**
6
- * List all enabled skills in standard MCP format.
7
- * Route: GET /api/skillHub:mcpListTools
8
- */
9
- listTools(ctx: any, next: any): Promise<void>;
10
- /**
11
- * Execute a skill in standard MCP format.
12
- * Route: POST /api/skillHub:mcpCallTool
13
- */
14
- callTool(ctx: any, next: any): Promise<void>;
15
- }
@@ -1,58 +0,0 @@
1
- import { SandboxRunner } from '../services/SandboxRunner';
2
- import { FileManager } from '../services/FileManager';
3
- import { SkillManager } from '../services/SkillManager';
4
- import { WorkerEnvManager } from '../services/WorkerEnvManager';
5
- export declare class SkillHubSubFeature {
6
- private plugin;
7
- sandboxRunner: SandboxRunner;
8
- fileManager: FileManager;
9
- skillManager: SkillManager;
10
- workerEnvManager: WorkerEnvManager;
11
- private cleanupInterval;
12
- private initEnvDoneCallback;
13
- private initEnvProgressCallback;
14
- private mcpController;
15
- private skillRepoService;
16
- private rateLimiter;
17
- private skillTemplates;
18
- constructor(plugin: any);
19
- get app(): any;
20
- get db(): any;
21
- get name(): any;
22
- load(): Promise<void>;
23
- private onQueueTask;
24
- /**
25
- * Execute skill — called by both AI tool and REST test endpoint.
26
- * Dispatches to worker via EventQueue, waits for result via PubSub.
27
- * Pushes progress to SSE via runtime.writer (if within AI tool context).
28
- * Includes rate limiting and graceful abort propagation.
29
- */
30
- executeSkill(skill: any, inputArgs: Record<string, any>, ctx?: any): Promise<any>;
31
- private handleDownload;
32
- private handleTest;
33
- /**
34
- * Handle Init Environment request from admin UI.
35
- * Dispatches init task to all workers via EventQueue.
36
- */
37
- private handleInitEnv;
38
- /**
39
- * Subscribe to init-env done AND progress PubSub channels.
40
- * When a worker finishes init, auto-update the DB with status.
41
- */
42
- private subscribeInitEnvDone;
43
- private registerAITools;
44
- private startCleanupInterval;
45
- beforeStop(): Promise<void>;
46
- private handleClearStorage;
47
- private handleListTemplates;
48
- /**
49
- * Register a skill template into memory for UI importing.
50
- */
51
- registerSkillTemplate(pluginName: string, skillDef: any): void;
52
- resolveSkillTemplate(templateName: string): any;
53
- getSkillDescriptionForAI(skill: any): Promise<string>;
54
- getSkillInstructions(skill: any): Promise<any>;
55
- private hydrateSkillTemplate;
56
- install(): Promise<void>;
57
- }
58
- export default SkillHubSubFeature;
@@ -1,16 +0,0 @@
1
- import Application from '@nocobase/server';
2
- import { SandboxRunner } from '../../services/SandboxRunner';
3
- import { FileManager } from '../../services/FileManager';
4
- import { SkillRepositoryService } from '../../services/SkillRepositoryService';
5
- export declare class SkillExecutionTask {
6
- private execution;
7
- private sandboxRunner;
8
- private fileManager;
9
- private skillRepoService;
10
- private app;
11
- constructor(execution: any, sandboxRunner: SandboxRunner, fileManager: FileManager, skillRepoService: SkillRepositoryService, app: Application);
12
- run(): Promise<void>;
13
- private renderTemplate;
14
- private installGeneratedSkillIfRequested;
15
- private validateGeneratedSkillPackages;
16
- }
@@ -1,7 +0,0 @@
1
- export declare function parseJsonText<T = any>(value: any, fallback: T): T;
2
- export declare function stringifyJsonText(value: any, fallback?: any): string;
3
- export declare function parseJsonLike(value: any, fallback: any): any;
4
- export declare function parseSkillMarkdown(markdown: string): {
5
- metadata: Record<string, any>;
6
- body: string;
7
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * Creates one dynamic tool per configured sub-agent for a given leader.
3
- * Uses Strategy B (Per-SubAgent Tool): each sub-agent becomes a separate tool
4
- * with its own name and description, making LLM tool selection natural.
5
- *
6
- * Architecture:
7
- * - Uses createReactAgent (public LangGraph API) for agent execution
8
- * - Uses plugin-ai's getLLMService() for LLM model resolution
9
- * - Uses core app.aiManager.toolsManager.listTools() for tool resolution
10
- * (same manager that AIEmployee uses — see ai-employee.ts:1286)
11
- * - Depth enforcement via ctx metadata tracking
12
- * - Per-leader scoping via invoke-time check (core ToolsOptions has no
13
- * leaderUsername field, so scoping is enforced in the invoke callback)
14
- */
15
- export declare function createDelegateToolsProvider(plugin: any): (register: any) => Promise<void>;
16
- /**
17
- * Test/internal helper to drop the in-memory tool cache (e.g., from a CLI op).
18
- */
19
- export declare function invalidateDelegateToolsCache(): void;
@@ -1,42 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function createExternalRagSearchTool(plugin: any): {
3
- scope: "CUSTOM";
4
- execution: "backend";
5
- defaultPermission: "ALLOW";
6
- introduction: {
7
- title: string;
8
- about: string;
9
- };
10
- definition: {
11
- name: string;
12
- description: string;
13
- schema: z.ZodObject<{
14
- query: z.ZodString;
15
- knowledgeBaseIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
- topK: z.ZodOptional<z.ZodNumber>;
17
- scoreThreshold: z.ZodOptional<z.ZodNumber>;
18
- }, "strip", z.ZodTypeAny, {
19
- query?: string;
20
- knowledgeBaseIds?: string[];
21
- topK?: number;
22
- scoreThreshold?: number;
23
- }, {
24
- query?: string;
25
- knowledgeBaseIds?: string[];
26
- topK?: number;
27
- scoreThreshold?: number;
28
- }>;
29
- };
30
- invoke: (ctx: any, args: {
31
- query?: string;
32
- knowledgeBaseIds?: string[];
33
- topK?: number;
34
- scoreThreshold?: number;
35
- }) => Promise<{
36
- status: "error";
37
- content: string;
38
- } | {
39
- status: "success";
40
- content: string;
41
- }>;
42
- };
@@ -1,36 +0,0 @@
1
- export declare function createSkillExecuteTool(plugin: any): {
2
- scope: string;
3
- execution: string;
4
- defaultPermission: string;
5
- introduction: {
6
- title: string;
7
- about: string;
8
- };
9
- definition: {
10
- name: string;
11
- description: string;
12
- schema: {
13
- type: string;
14
- properties: {
15
- action: {
16
- type: string;
17
- enum: string[];
18
- description: string;
19
- };
20
- skillName: {
21
- type: string;
22
- description: string;
23
- };
24
- input: {
25
- type: string;
26
- description: string;
27
- };
28
- };
29
- required: string[];
30
- };
31
- };
32
- invoke(ctx: any, args: Record<string, any>, _id?: string): Promise<{
33
- status: string;
34
- content: string;
35
- }>;
36
- };