plugin-agent-orchestrator 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +204 -114
  2. package/dist/client/index.js +1 -1
  3. package/dist/client-v2/117.7565cff57c39318a.js +10 -0
  4. package/dist/client-v2/214.106635011859dede.js +10 -0
  5. package/dist/client-v2/418.41ed200e7d6da332.js +10 -0
  6. package/dist/client-v2/53.349fff8db80b19d4.js +10 -0
  7. package/dist/client-v2/981.e4a1f41cfc94a856.js +10 -0
  8. package/dist/client-v2/index.js +1 -1
  9. package/dist/externalVersion.js +7 -8
  10. package/dist/locale/en-US.json +226 -170
  11. package/dist/locale/vi-VN.json +226 -170
  12. package/dist/locale/zh-CN.json +226 -170
  13. package/dist/server/collections/agent-execution-spans.js +8 -0
  14. package/dist/server/collections/agent-loop-action-approvals.js +1 -0
  15. package/dist/server/collections/agent-loop-runs.js +7 -1
  16. package/dist/server/collections/agent-loop-steps.js +7 -0
  17. package/dist/server/collections/skill-executions.js +8 -0
  18. package/dist/server/plugin.js +3 -1
  19. package/dist/server/resources/agent-harness-profile.js +117 -0
  20. package/dist/server/resources/agent-knowledge-insights.js +1 -3
  21. package/dist/server/resources/agent-loop-approval.js +25 -0
  22. package/dist/server/resources/agent-loop.js +3 -1
  23. package/dist/server/services/AgentMemoryContextService.js +34 -0
  24. package/dist/server/services/HarnessCompiler.js +35 -2
  25. package/dist/server/services/HarnessProfileService.js +74 -9
  26. package/dist/server/services/HarnessSchema.js +30 -3
  27. package/dist/server/services/LoopPatternSchema.js +16 -1
  28. package/dist/server/services/LoopRunRepository.js +80 -0
  29. package/dist/server/services/LoopRunStateMachine.js +92 -3
  30. package/dist/server/services/LoopTriggerService.js +37 -0
  31. package/dist/server/services/LoopWorkerService.js +261 -23
  32. package/dist/server/services/NativeSubAgentObserver.js +165 -23
  33. package/dist/server/services/PluginAiRuntimeAdapter.js +16 -5
  34. package/dist/server/services/ToolLoopDetectionService.js +210 -0
  35. package/dist/server/services/VerificationService.js +66 -0
  36. package/dist/server/services/harness-runtime-policy.js +139 -0
  37. package/dist/server/skill-hub/plugin.js +36 -3
  38. package/dist/server/skill-hub/tasks/SkillExecutionTask.js +29 -0
  39. package/package.json +53 -53
  40. package/src/client/ApprovalsTab.tsx +2 -0
  41. package/src/client/OrchestratorSettings.tsx +11 -0
  42. package/src/client/skill-hub/components/GitSkillImport.tsx +3 -3
  43. package/src/client/skill-hub/components/SkillMetrics.tsx +15 -10
  44. package/src/client/skill-hub/index.tsx +0 -52
  45. package/src/client-v2/components/AgentRunsTab.tsx +576 -576
  46. package/src/client-v2/components/ApprovalsTab.tsx +337 -0
  47. package/src/client-v2/components/HarnessProfilesTab.tsx +385 -105
  48. package/src/client-v2/components/MemoryInspectorTab.tsx +141 -141
  49. package/src/client-v2/components/TracingTab.tsx +515 -515
  50. package/src/client-v2/hooks/useApiRequest.ts +141 -141
  51. package/src/client-v2/pages/ApprovalsPage.tsx +10 -0
  52. package/src/client-v2/plugin.tsx +6 -6
  53. package/src/client-v2/skill-hub/components/SkillMetrics.tsx +5 -2
  54. package/src/locale/en-US.json +226 -174
  55. package/src/locale/vi-VN.json +226 -174
  56. package/src/locale/zh-CN.json +226 -174
  57. package/src/server/__tests__/circuit-breaker.test.ts +248 -248
  58. package/src/server/__tests__/harness-compiler.test.ts +83 -0
  59. package/src/server/__tests__/harness-profile-service.test.ts +51 -0
  60. package/src/server/__tests__/harness-runtime-policy.test.ts +293 -0
  61. package/src/server/__tests__/harness-tool-plan.test.ts +24 -0
  62. package/src/server/__tests__/loop-approval-decision.test.ts +512 -0
  63. package/src/server/__tests__/loop-approval-expiry.test.ts +258 -0
  64. package/src/server/__tests__/loop-budget-service.test.ts +255 -255
  65. package/src/server/__tests__/loop-control-plane-backfill.test.ts +266 -266
  66. package/src/server/__tests__/loop-pattern-schema.test.ts +18 -1
  67. package/src/server/__tests__/loop-pattern-service.test.ts +148 -148
  68. package/src/server/__tests__/loop-run-state-machine.test.ts +11 -0
  69. package/src/server/__tests__/loop-trigger-service.test.ts +148 -0
  70. package/src/server/__tests__/loop-worker-claim.test.ts +341 -341
  71. package/src/server/__tests__/loop-worker-execution.test.ts +82 -1
  72. package/src/server/__tests__/native-sub-agent-observer.test.ts +288 -4
  73. package/src/server/__tests__/path-lock-service.test.ts +254 -254
  74. package/src/server/__tests__/skill-execution-task-policy.test.ts +140 -0
  75. package/src/server/__tests__/smoke.test.ts +162 -162
  76. package/src/server/__tests__/tool-loop-detection.test.ts +275 -0
  77. package/src/server/collections/agent-execution-spans.ts +8 -0
  78. package/src/server/collections/agent-harness-profile-versions.ts +26 -26
  79. package/src/server/collections/agent-harness-profiles.ts +71 -71
  80. package/src/server/collections/agent-loop-action-approvals.ts +1 -0
  81. package/src/server/collections/agent-loop-artifacts.ts +25 -25
  82. package/src/server/collections/agent-loop-circuit-states.ts +23 -23
  83. package/src/server/collections/agent-loop-control-settings.ts +21 -21
  84. package/src/server/collections/agent-loop-events.ts +98 -98
  85. package/src/server/collections/agent-loop-path-locks.ts +27 -27
  86. package/src/server/collections/agent-loop-patterns.ts +42 -42
  87. package/src/server/collections/agent-loop-runs.ts +7 -1
  88. package/src/server/collections/agent-loop-steps.ts +7 -0
  89. package/src/server/collections/agent-loop-usage-buckets.ts +22 -22
  90. package/src/server/collections/agent-loop-worktrees.ts +25 -25
  91. package/src/server/collections/skill-executions.ts +8 -0
  92. package/src/server/migrations/20260427000002-change-packages-to-text.ts +52 -52
  93. package/src/server/migrations/20260429000000-add-llm-fields.ts +47 -47
  94. package/src/server/migrations/20260429000001-fix-inputargs-json-to-text.ts +45 -45
  95. package/src/server/migrations/20260503000000-add-orchestrator-trace-fields.ts +33 -33
  96. package/src/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.ts +31 -31
  97. package/src/server/migrations/20260803010000-backfill-loop-control-plane-data.ts +293 -293
  98. package/src/server/plugin.ts +3 -1
  99. package/src/server/resources/agent-harness-profile.ts +94 -0
  100. package/src/server/resources/agent-knowledge-insights.ts +5 -3
  101. package/src/server/resources/agent-loop-approval.ts +32 -0
  102. package/src/server/resources/agent-loop-artifact.ts +56 -56
  103. package/src/server/resources/agent-loop-events-stream.ts +105 -105
  104. package/src/server/resources/agent-loop.ts +3 -1
  105. package/src/server/resources/resource-helpers.ts +33 -33
  106. package/src/server/resources/tracing.ts +266 -266
  107. package/src/server/services/AgentMemoryContextService.ts +44 -0
  108. package/src/server/services/DurableCircuitBreakerService.ts +239 -239
  109. package/src/server/services/ExecutionSpanService.ts +2 -0
  110. package/src/server/services/HarnessCompiler.ts +37 -0
  111. package/src/server/services/HarnessProfileService.ts +92 -10
  112. package/src/server/services/HarnessSchema.ts +31 -0
  113. package/src/server/services/LoopBudgetService.ts +275 -275
  114. package/src/server/services/LoopControlService.ts +124 -124
  115. package/src/server/services/LoopPatternSchema.ts +19 -1
  116. package/src/server/services/LoopPatternService.ts +143 -143
  117. package/src/server/services/LoopRunRepository.ts +99 -0
  118. package/src/server/services/LoopRunStateMachine.ts +100 -3
  119. package/src/server/services/LoopSchedulerService.ts +199 -199
  120. package/src/server/services/LoopTriggerService.ts +42 -0
  121. package/src/server/services/LoopWorkerService.ts +327 -27
  122. package/src/server/services/NativeSubAgentObserver.ts +186 -21
  123. package/src/server/services/PathLockService.ts +321 -321
  124. package/src/server/services/PluginAiRuntimeAdapter.ts +24 -7
  125. package/src/server/services/ToolLoopDetectionService.ts +213 -0
  126. package/src/server/services/VerificationSchema.ts +31 -31
  127. package/src/server/services/VerificationService.ts +81 -2
  128. package/src/server/services/harness-runtime-policy.ts +141 -0
  129. package/src/server/skill-hub/plugin.ts +41 -3
  130. package/src/server/skill-hub/services/RegistrySkillSnapshotService.ts +235 -235
  131. package/src/server/skill-hub/services/__tests__/RegistrySkillSnapshotService.test.ts +61 -61
  132. package/src/server/skill-hub/tasks/SkillExecutionTask.ts +43 -2
  133. package/src/server/utils/ensure-indexes.ts +96 -96
  134. package/src/server/utils/logging.ts +62 -62
  135. package/src/server/utils/loop-pattern-context.ts +20 -20
  136. package/dist/client-v2/214.b063f33ba044a808.js +0 -10
  137. package/dist/client-v2/373.f5d5292e53c4e832.js +0 -10
  138. package/dist/client-v2/418.58fa350f5496efd3.js +0 -10
  139. package/dist/client-v2/53.9a10455323390f14.js +0 -10
  140. package/dist/client-v2/677.a991ce0250ff5c77.js +0 -10
  141. package/dist/client-v2/925.e5925bf21ed68e7a.js +0 -10
  142. package/src/client/AIEmployeeSelect.tsx +0 -47
  143. package/src/client/AIEmployeesContext.tsx +0 -102
  144. package/src/client/RulesTab.tsx +0 -2
  145. package/src/client/TracingTab.tsx +0 -436
  146. package/src/client/skill-hub/components/ExecutionProgress.tsx +0 -51
  147. package/src/client-v2/components/RulesTab.tsx +0 -2
  148. package/src/client-v2/pages/AgentRunsPage.tsx +0 -13
@@ -1,141 +1,141 @@
1
- import { useApp } from '@nocobase/client-v2';
2
- import { useCallback, useEffect, useRef, useState } from 'react';
3
-
4
- /**
5
- * client-v2 adapters for the two data-layer hooks the v1 admin tabs relied on
6
- * (`useAPIClient` and `useRequest` from `@nocobase/client`). client-v2 exposes
7
- * neither, so these reimplement just the slice the orchestrator UI uses on top
8
- * of `useApp().apiClient`, keeping the call sites unchanged.
9
- *
10
- * v1 contract preserved here:
11
- * - `useRequest` resolves `data` to the response BODY (`response.data`), so a
12
- * list endpoint returning `{ data: rows, meta }` is read as `result.data.data`
13
- * / `result.data.meta` — identical to the v1 tabs.
14
- */
15
-
16
- export type ApiRequestService =
17
- | {
18
- url: string;
19
- method?: string;
20
- params?: Record<string, unknown>;
21
- data?: unknown;
22
- }
23
- | (() => Promise<unknown>);
24
-
25
- export type ApiRequestOptions = {
26
- /** Do not fire on mount; caller triggers via `run`. */
27
- manual?: boolean;
28
- /** Re-run whenever any dependency changes (mirrors ahooks refreshDeps). */
29
- refreshDeps?: unknown[];
30
- onSuccess?: (data: unknown) => void;
31
- onError?: (error: unknown) => void;
32
- };
33
-
34
- export type ApiRequestResult<TData = unknown> = {
35
- data: TData | undefined;
36
- loading: boolean;
37
- error: unknown;
38
- refresh: () => void;
39
- run: (overrideParams?: Record<string, unknown>) => Promise<TData | undefined>;
40
- };
41
-
42
- /** Returns the v2 application's API client (replacement for v1 `useAPIClient`). */
43
- export function useApiClient() {
44
- return useApp().apiClient;
45
- }
46
-
47
- /**
48
- * Minimal `useRequest` replacement. Supports object services
49
- * (`{ url, method, params }`) and function services, plus `manual`,
50
- * `refreshDeps`, and `onSuccess`/`onError` — the only options the tabs use.
51
- */
52
- export function useRequest<TData = unknown>(
53
- service: ApiRequestService,
54
- options: ApiRequestOptions = {},
55
- ): ApiRequestResult<TData> {
56
- const api = useApiClient();
57
- const { manual = false, refreshDeps = [], onSuccess, onError } = options;
58
-
59
- const [data, setData] = useState<TData | undefined>(undefined);
60
- const [loading, setLoading] = useState<boolean>(!manual);
61
- const [error, setError] = useState<unknown>(undefined);
62
-
63
- // Keep the latest service/callbacks without forcing them into refreshDeps.
64
- const serviceRef = useRef(service);
65
- serviceRef.current = service;
66
- const onSuccessRef = useRef(onSuccess);
67
- onSuccessRef.current = onSuccess;
68
- const onErrorRef = useRef(onError);
69
- onErrorRef.current = onError;
70
-
71
- // Guards against out-of-order responses and post-unmount state writes.
72
- // Each `run` claims a monotonically increasing id; only the newest in-flight
73
- // request is allowed to commit results, and none may commit after unmount.
74
- const mountedRef = useRef(true);
75
- const latestRequestId = useRef(0);
76
- useEffect(() => {
77
- mountedRef.current = true;
78
- return () => {
79
- mountedRef.current = false;
80
- };
81
- }, []);
82
-
83
- const run = useCallback(
84
- async (overrideParams?: Record<string, unknown>): Promise<TData | undefined> => {
85
- const current = serviceRef.current;
86
- const requestId = ++latestRequestId.current;
87
- const isCurrent = () => mountedRef.current && requestId === latestRequestId.current;
88
- setLoading(true);
89
- setError(undefined);
90
- try {
91
- let body: TData;
92
- if (typeof current === 'function') {
93
- body = (await current()) as TData;
94
- } else {
95
- const response = await api.request({
96
- url: current.url,
97
- method: current.method || 'get',
98
- params: { ...(current.params || {}), ...(overrideParams || {}) },
99
- data: current.data,
100
- });
101
- const rawData = response?.data;
102
- body = (
103
- rawData &&
104
- typeof rawData === 'object' &&
105
- rawData.data &&
106
- typeof rawData.data === 'object' &&
107
- 'data' in rawData.data
108
- ? rawData.data
109
- : rawData
110
- ) as TData;
111
- }
112
- if (!isCurrent()) return undefined;
113
- setData(body);
114
- onSuccessRef.current?.(body);
115
- return body;
116
- } catch (err) {
117
- if (!isCurrent()) return undefined;
118
- setError(err);
119
- onErrorRef.current?.(err);
120
- return undefined;
121
- } finally {
122
- if (isCurrent()) {
123
- setLoading(false);
124
- }
125
- }
126
- },
127
- [api],
128
- );
129
-
130
- const refresh = useCallback(() => {
131
- run();
132
- }, [run]);
133
-
134
- useEffect(() => {
135
- if (manual) return;
136
- run();
137
- // eslint-disable-next-line react-hooks/exhaustive-deps
138
- }, refreshDeps);
139
-
140
- return { data, loading, error, refresh, run };
141
- }
1
+ import { useApp } from '@nocobase/client-v2';
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+
4
+ /**
5
+ * client-v2 adapters for the two data-layer hooks the v1 admin tabs relied on
6
+ * (`useAPIClient` and `useRequest` from `@nocobase/client`). client-v2 exposes
7
+ * neither, so these reimplement just the slice the orchestrator UI uses on top
8
+ * of `useApp().apiClient`, keeping the call sites unchanged.
9
+ *
10
+ * v1 contract preserved here:
11
+ * - `useRequest` resolves `data` to the response BODY (`response.data`), so a
12
+ * list endpoint returning `{ data: rows, meta }` is read as `result.data.data`
13
+ * / `result.data.meta` — identical to the v1 tabs.
14
+ */
15
+
16
+ export type ApiRequestService =
17
+ | {
18
+ url: string;
19
+ method?: string;
20
+ params?: Record<string, unknown>;
21
+ data?: unknown;
22
+ }
23
+ | (() => Promise<unknown>);
24
+
25
+ export type ApiRequestOptions = {
26
+ /** Do not fire on mount; caller triggers via `run`. */
27
+ manual?: boolean;
28
+ /** Re-run whenever any dependency changes (mirrors ahooks refreshDeps). */
29
+ refreshDeps?: unknown[];
30
+ onSuccess?: (data: unknown) => void;
31
+ onError?: (error: unknown) => void;
32
+ };
33
+
34
+ export type ApiRequestResult<TData = unknown> = {
35
+ data: TData | undefined;
36
+ loading: boolean;
37
+ error: unknown;
38
+ refresh: () => void;
39
+ run: (overrideParams?: Record<string, unknown>) => Promise<TData | undefined>;
40
+ };
41
+
42
+ /** Returns the v2 application's API client (replacement for v1 `useAPIClient`). */
43
+ export function useApiClient() {
44
+ return useApp().apiClient;
45
+ }
46
+
47
+ /**
48
+ * Minimal `useRequest` replacement. Supports object services
49
+ * (`{ url, method, params }`) and function services, plus `manual`,
50
+ * `refreshDeps`, and `onSuccess`/`onError` — the only options the tabs use.
51
+ */
52
+ export function useRequest<TData = unknown>(
53
+ service: ApiRequestService,
54
+ options: ApiRequestOptions = {},
55
+ ): ApiRequestResult<TData> {
56
+ const api = useApiClient();
57
+ const { manual = false, refreshDeps = [], onSuccess, onError } = options;
58
+
59
+ const [data, setData] = useState<TData | undefined>(undefined);
60
+ const [loading, setLoading] = useState<boolean>(!manual);
61
+ const [error, setError] = useState<unknown>(undefined);
62
+
63
+ // Keep the latest service/callbacks without forcing them into refreshDeps.
64
+ const serviceRef = useRef(service);
65
+ serviceRef.current = service;
66
+ const onSuccessRef = useRef(onSuccess);
67
+ onSuccessRef.current = onSuccess;
68
+ const onErrorRef = useRef(onError);
69
+ onErrorRef.current = onError;
70
+
71
+ // Guards against out-of-order responses and post-unmount state writes.
72
+ // Each `run` claims a monotonically increasing id; only the newest in-flight
73
+ // request is allowed to commit results, and none may commit after unmount.
74
+ const mountedRef = useRef(true);
75
+ const latestRequestId = useRef(0);
76
+ useEffect(() => {
77
+ mountedRef.current = true;
78
+ return () => {
79
+ mountedRef.current = false;
80
+ };
81
+ }, []);
82
+
83
+ const run = useCallback(
84
+ async (overrideParams?: Record<string, unknown>): Promise<TData | undefined> => {
85
+ const current = serviceRef.current;
86
+ const requestId = ++latestRequestId.current;
87
+ const isCurrent = () => mountedRef.current && requestId === latestRequestId.current;
88
+ setLoading(true);
89
+ setError(undefined);
90
+ try {
91
+ let body: TData;
92
+ if (typeof current === 'function') {
93
+ body = (await current()) as TData;
94
+ } else {
95
+ const response = await api.request({
96
+ url: current.url,
97
+ method: current.method || 'get',
98
+ params: { ...(current.params || {}), ...(overrideParams || {}) },
99
+ data: current.data,
100
+ });
101
+ const rawData = response?.data;
102
+ body = (
103
+ rawData &&
104
+ typeof rawData === 'object' &&
105
+ rawData.data &&
106
+ typeof rawData.data === 'object' &&
107
+ 'data' in rawData.data
108
+ ? rawData.data
109
+ : rawData
110
+ ) as TData;
111
+ }
112
+ if (!isCurrent()) return undefined;
113
+ setData(body);
114
+ onSuccessRef.current?.(body);
115
+ return body;
116
+ } catch (err) {
117
+ if (!isCurrent()) return undefined;
118
+ setError(err);
119
+ onErrorRef.current?.(err);
120
+ return undefined;
121
+ } finally {
122
+ if (isCurrent()) {
123
+ setLoading(false);
124
+ }
125
+ }
126
+ },
127
+ [api],
128
+ );
129
+
130
+ const refresh = useCallback(() => {
131
+ run();
132
+ }, [run]);
133
+
134
+ useEffect(() => {
135
+ if (manual) return;
136
+ run();
137
+ // eslint-disable-next-line react-hooks/exhaustive-deps
138
+ }, refreshDeps);
139
+
140
+ return { data, loading, error, refresh, run };
141
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ApprovalsTab } from '../components/ApprovalsTab';
3
+
4
+ const ApprovalsPage: React.FC = () => (
5
+ <div style={{ padding: '0 24px 24px' }}>
6
+ <ApprovalsTab />
7
+ </div>
8
+ );
9
+
10
+ export default ApprovalsPage;
@@ -25,16 +25,16 @@ export class PluginAgentOrchestratorClient extends Plugin<Record<string, never>,
25
25
 
26
26
  this.pluginSettingsManager.addPageTabItem({
27
27
  menuKey: 'ai.orchestrator',
28
- key: 'agent-runs',
29
- title: this.t('Native Agent Runs'),
30
- componentLoader: () => import('./pages/AgentRunsPage'),
28
+ key: 'harness-profiles',
29
+ title: this.t('Policy Profiles'),
30
+ componentLoader: () => import('./pages/HarnessProfilesPage'),
31
31
  });
32
32
 
33
33
  this.pluginSettingsManager.addPageTabItem({
34
34
  menuKey: 'ai.orchestrator',
35
- key: 'harness-profiles',
36
- title: this.t('Policy Profiles'),
37
- componentLoader: () => import('./pages/HarnessProfilesPage'),
35
+ key: 'approvals',
36
+ title: this.t('Approvals'),
37
+ componentLoader: () => import('./pages/ApprovalsPage'),
38
38
  });
39
39
 
40
40
  this.pluginSettingsManager.addPageTabItem({
@@ -26,9 +26,12 @@ export const SkillMetrics: React.FC = () => {
26
26
  });
27
27
  const rawData = data?.data?.data ?? data?.data ?? [];
28
28
  setExecutions(Array.isArray(rawData) ? rawData : []);
29
- } catch (err: any) {
29
+ } catch (err) {
30
+ const response = err as { response?: { data?: { errors?: { message?: string }[] } } };
30
31
  setExecutions([]);
31
- setError(err?.response?.data?.errors?.[0]?.message || err?.message || t('Failed to load metrics'));
32
+ setError(
33
+ response?.response?.data?.errors?.[0]?.message || (err as Error)?.message || t('Failed to load metrics'),
34
+ );
32
35
  } finally {
33
36
  setLoading(false);
34
37
  }