plugin-agent-orchestrator 1.1.6 → 1.1.7

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 (69) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/client-v2/index.js +1 -1
  3. package/dist/externalVersion.js +7 -7
  4. package/dist/server/collections/agent-loop-runs.js +6 -0
  5. package/dist/server/collections/skill-metrics.js +66 -0
  6. package/dist/server/plugin.js +91 -2
  7. package/dist/server/resources/agent-loop-events-stream.js +1 -0
  8. package/dist/server/resources/agent-loop.js +1 -1
  9. package/dist/server/services/DurableCircuitBreakerService.js +9 -12
  10. package/dist/server/services/ExecutionSpanService.js +8 -3
  11. package/dist/server/services/HarnessProfileService.js +23 -26
  12. package/dist/server/services/LoopBudgetService.js +36 -39
  13. package/dist/server/services/LoopControlService.js +8 -11
  14. package/dist/server/services/LoopPatternSchema.js +51 -17
  15. package/dist/server/services/LoopPatternService.js +31 -11
  16. package/dist/server/services/LoopRunRepository.js +2 -5
  17. package/dist/server/services/LoopRunStateMachine.js +31 -34
  18. package/dist/server/services/LoopSchedulerService.js +4 -7
  19. package/dist/server/services/LoopTriggerService.js +11 -6
  20. package/dist/server/services/LoopWorkerService.js +88 -22
  21. package/dist/server/services/PathLockService.js +19 -22
  22. package/dist/server/services/PluginAiRuntimeAdapter.js +51 -8
  23. package/dist/server/services/RunEventBus.js +14 -2
  24. package/dist/server/services/SkillAccessService.js +50 -1
  25. package/dist/server/services/TokenTracker.js +17 -1
  26. package/dist/server/services/ToolLoopDetectionService.js +14 -17
  27. package/dist/server/services/VerificationService.js +47 -16
  28. package/dist/server/services/harness-runtime-policy.js +7 -12
  29. package/dist/server/skill-hub/plugin.js +34 -27
  30. package/dist/server/utils/ha-lock.js +73 -0
  31. package/dist/server/utils/loop-pattern-context.js +42 -5
  32. package/dist/server/utils/record-utils.js +44 -0
  33. package/package.json +1 -1
  34. package/src/client/plugin.tsx +1 -1
  35. package/src/client-v2/plugin.tsx +14 -13
  36. package/src/server/__tests__/tool-loop-detection.test.ts +1 -0
  37. package/src/server/collections/agent-loop-runs.ts +7 -0
  38. package/src/server/collections/skill-metrics.ts +36 -0
  39. package/src/server/plugin.ts +117 -1
  40. package/src/server/resources/agent-loop-events-stream.ts +108 -105
  41. package/src/server/resources/agent-loop.ts +1 -1
  42. package/src/server/resources/tracing.ts +267 -266
  43. package/src/server/services/DurableCircuitBreakerService.ts +235 -239
  44. package/src/server/services/ExecutionSpanService.ts +37 -12
  45. package/src/server/services/HarnessProfileService.ts +1 -5
  46. package/src/server/services/LoopBudgetService.ts +271 -275
  47. package/src/server/services/LoopControlService.ts +120 -124
  48. package/src/server/services/LoopPatternSchema.ts +60 -14
  49. package/src/server/services/LoopPatternService.ts +171 -143
  50. package/src/server/services/LoopRunRepository.ts +1 -5
  51. package/src/server/services/LoopRunStateMachine.ts +1 -5
  52. package/src/server/services/LoopSchedulerService.ts +195 -199
  53. package/src/server/services/LoopTriggerService.ts +7 -5
  54. package/src/server/services/LoopWorkerService.ts +102 -12
  55. package/src/server/services/PathLockService.ts +317 -321
  56. package/src/server/services/PluginAiRuntimeAdapter.ts +59 -4
  57. package/src/server/services/RunEventBus.ts +13 -0
  58. package/src/server/services/SkillAccessService.ts +80 -5
  59. package/src/server/services/TokenTracker.ts +59 -7
  60. package/src/server/services/ToolLoopDetectionService.ts +8 -11
  61. package/src/server/services/VerificationSchema.ts +31 -31
  62. package/src/server/services/VerificationService.ts +60 -11
  63. package/src/server/services/harness-runtime-policy.ts +2 -9
  64. package/src/server/skill-hub/plugin.ts +36 -28
  65. package/src/server/types.ts +5 -39
  66. package/src/server/utils/ensure-indexes.ts +96 -96
  67. package/src/server/utils/ha-lock.ts +80 -0
  68. package/src/server/utils/loop-pattern-context.ts +84 -20
  69. package/src/server/utils/record-utils.ts +19 -0
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons")):"function"==typeof define&&define.amd?define("plugin-agent-orchestrator/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons"],t):"object"==typeof exports?exports["plugin-agent-orchestrator/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons")):e["plugin-agent-orchestrator/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"])}(self,function(e,t,n,r){return function(){"use strict";var o,i,a,c={375:function(e){e.exports=r},485:function(t){t.exports=e},59:function(e){e.exports=n},155:function(e){e.exports=t}},u={};function l(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,l),n.exports}l.m=c,l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.f={},l.e=function(e){return Promise.all(Object.keys(l.f).reduce(function(t,n){return l.f[n](e,t),t},[]))},l.u=function(e){return""+e+"."+({117:"7565cff57c39318a",214:"106635011859dede",253:"59577b40d9875be0",264:"7ed8bee71fa5935c",41:"3deb9e57a0f64fc4",418:"41ed200e7d6da332",53:"349fff8db80b19d4",619:"0a2144aaffefe018",70:"ffff2997c10fd4b0",794:"a67a2614405ba627",981:"e4a1f41cfc94a856",993:"b0688fdc5ccb000a"})[e]+".js"},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},l.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var u=a[c];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="plugin-agent-orchestrator/client-v2:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,l.nc&&o.setAttribute("nonce",l.nc),o.setAttribute("data-rspack","plugin-agent-orchestrator/client-v2:"+n),o.src=e),s[e]=[t];var p=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),i&&document.head.appendChild(o)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(p=l.g.location+"");var s,p,f=l.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var d=f.getElementsByTagName("script");if(d.length)for(var h=d.length-1;h>-1&&(!p||!/^http(s?):/.test(p));)p=d[h--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");l.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o={889:0},l.f.j=function(e,t){var n=l.o(o,e)?o[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=o[e]=[t,r]});t.push(n[2]=r);var i=l.p+l.u(e),a=Error();l.l(i,function(t){if(l.o(o,e)&&(0!==(n=o[e])&&(o[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,n[1](a)}},"chunk-"+e,e)}},i=function(e,t){var n,r,i=t[0],a=t[1],c=t[2],u=0;if(i.some(function(e){return 0!==o[e]})){for(n in a)l.o(a,n)&&(l.m[n]=a[n]);c&&c(l)}for(e&&e(t);u<i.length;u++)r=i[u],l.o(o,r)&&o[r]&&o[r][0](),o[r]=0},(a=self.webpackChunkplugin_agent_orchestrator_client_v2=self.webpackChunkplugin_agent_orchestrator_client_v2||[]).forEach(i.bind(null,0)),a.push=i.bind(null,a.push.bind(a));var g={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-agent-orchestrator/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-agent-orchestrator/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf(i);e=c>=0?a.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-agent-orchestrator/dist/client-v2/"}l.p=e}(),!function(){l.r(g),l.d(g,{default:function(){return c}});var e=l(485);function t(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var c=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:u(0)}),c(a,"throw",{value:u(1)}),c(a,"return",{value:u(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function u(c){return function(u){var l=[c,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"ai.orchestrator",title:this.t("Agent Orchestrator"),icon:"ApartmentOutlined"}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"index",title:this.t("Native Monitor"),componentLoader:function(){return l.e("117").then(l.bind(l,524))},sort:-1}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"tracing",title:this.t("Execution Tracing"),componentLoader:function(){return l.e("619").then(l.bind(l,230))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"harness-profiles",title:this.t("Policy Profiles"),componentLoader:function(){return l.e("418").then(l.bind(l,393))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"approvals",title:this.t("Approvals"),componentLoader:function(){return l.e("981").then(l.bind(l,396))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"agent-bindings",title:this.t("Agent Bindings"),componentLoader:function(){return l.e("794").then(l.bind(l,913))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"knowledge-access",title:this.t("Knowledge Access"),componentLoader:function(){return l.e("253").then(l.bind(l,740))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"retrieval-trace",title:this.t("Retrieval Trace"),componentLoader:function(){return l.e("993").then(l.bind(l,928))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"memory-inspector",title:this.t("Memory Inspector"),componentLoader:function(){return l.e("53").then(l.bind(l,676))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"skill-definitions",title:this.t("Skill Hub Definitions"),componentLoader:function(){return l.e("41").then(l.bind(l,224))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"skill-executions",title:this.t("Execution History"),componentLoader:function(){return l.e("264").then(l.bind(l,715))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"skill-loop-settings",title:this.t("Skill Review Settings"),componentLoader:function(){return l.e("70").then(l.bind(l,581))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai.orchestrator",key:"skill-metrics",title:this.t("Metrics"),componentLoader:function(){return l.e("214").then(l.bind(l,349))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function c(e){t(a,o,i,c,u,"next",e)}function u(e){t(a,o,i,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),g}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons")):"function"==typeof define&&define.amd?define("plugin-agent-orchestrator/client-v2",["@nocobase/client-v2","react","antd","@ant-design/icons"],t):"object"==typeof exports?exports["plugin-agent-orchestrator/client-v2"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@ant-design/icons")):e["plugin-agent-orchestrator/client-v2"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@ant-design/icons"])}(self,function(e,t,n,r){return function(){"use strict";var o,i,a,c={375:function(e){e.exports=r},485:function(t){t.exports=e},59:function(e){e.exports=n},155:function(e){e.exports=t}},u={};function l(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return c[e](n,n.exports,l),n.exports}l.m=c,l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.f={},l.e=function(e){return Promise.all(Object.keys(l.f).reduce(function(t,n){return l.f[n](e,t),t},[]))},l.u=function(e){return""+e+"."+({117:"7565cff57c39318a",214:"106635011859dede",253:"59577b40d9875be0",264:"7ed8bee71fa5935c",41:"3deb9e57a0f64fc4",418:"41ed200e7d6da332",53:"349fff8db80b19d4",619:"0a2144aaffefe018",70:"ffff2997c10fd4b0",794:"a67a2614405ba627",981:"e4a1f41cfc94a856",993:"b0688fdc5ccb000a"})[e]+".js"},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s={},l.l=function(e,t,n,r){if(s[e])return void s[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var u=a[c];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="plugin-agent-orchestrator/client-v2:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,l.nc&&o.setAttribute("nonce",l.nc),o.setAttribute("data-rspack","plugin-agent-orchestrator/client-v2:"+n),o.src=e),s[e]=[t];var p=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=s[e];if(delete s[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),i&&document.head.appendChild(o)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(p=l.g.location+"");var s,p,f=l.g.document;if(!p&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(p=f.currentScript.src),!p)){var d=f.getElementsByTagName("script");if(d.length)for(var h=d.length-1;h>-1&&(!p||!/^http(s?):/.test(p));)p=d[h--].src}if(!p)throw Error("Automatic publicPath is not supported in this browser");l.p=p.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o={889:0},l.f.j=function(e,t){var n=l.o(o,e)?o[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=o[e]=[t,r]});t.push(n[2]=r);var i=l.p+l.u(e),a=Error();l.l(i,function(t){if(l.o(o,e)&&(0!==(n=o[e])&&(o[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,n[1](a)}},"chunk-"+e,e)}},i=function(e,t){var n,r,i=t[0],a=t[1],c=t[2],u=0;if(i.some(function(e){return 0!==o[e]})){for(n in a)l.o(a,n)&&(l.m[n]=a[n]);c&&c(l)}for(e&&e(t);u<i.length;u++)r=i[u],l.o(o,r)&&o[r]&&o[r][0](),o[r]=0},(a=self.webpackChunkplugin_agent_orchestrator_client_v2=self.webpackChunkplugin_agent_orchestrator_client_v2||[]).forEach(i.bind(null,0)),a.push=i.bind(null,a.push.bind(a));var g={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-agent-orchestrator/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-agent-orchestrator/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",c=a.indexOf(i);e=c>=0?a.slice(0,c+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-agent-orchestrator/dist/client-v2/"}l.p=e}(),!function(){l.r(g),l.d(g,{default:function(){return c}});var e=l(485);function t(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&o(i,n.prototype),i}).apply(null,arguments)}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,r(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),o(i,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var c=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function i(){var e,t;if(!(this instanceof i))throw TypeError("Cannot call a class as a function");return e=i,t=arguments,e=r(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],r(this).constructor):e.apply(this,t))}return i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&o(i,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:u(0)}),c(a,"throw",{value:u(1)}),c(a,"return",{value:u(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function u(c){return function(u){var l=[c,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.pluginSettingsManager.addMenuItem({key:"ai-orchestrator",title:this.t("Agent Orchestrator"),icon:"ApartmentOutlined",aclSnippet:"pm.ai-orchestrator"}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"index",title:this.t("Native Monitor"),componentLoader:function(){return l.e("117").then(l.bind(l,524))},sort:-1}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"tracing",title:this.t("Execution Tracing"),componentLoader:function(){return l.e("619").then(l.bind(l,230))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"harness-profiles",title:this.t("Policy Profiles"),componentLoader:function(){return l.e("418").then(l.bind(l,393))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"approvals",title:this.t("Approvals"),componentLoader:function(){return l.e("981").then(l.bind(l,396))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"agent-bindings",title:this.t("Agent Bindings"),componentLoader:function(){return l.e("794").then(l.bind(l,913))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"knowledge-access",title:this.t("Knowledge Access"),componentLoader:function(){return l.e("253").then(l.bind(l,740))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"retrieval-trace",title:this.t("Retrieval Trace"),componentLoader:function(){return l.e("993").then(l.bind(l,928))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"memory-inspector",title:this.t("Memory Inspector"),componentLoader:function(){return l.e("53").then(l.bind(l,676))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"skill-definitions",title:this.t("Skill Hub Definitions"),componentLoader:function(){return l.e("41").then(l.bind(l,224))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"skill-executions",title:this.t("Execution History"),componentLoader:function(){return l.e("264").then(l.bind(l,715))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"skill-loop-settings",title:this.t("Skill Review Settings"),componentLoader:function(){return l.e("70").then(l.bind(l,581))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"ai-orchestrator",key:"skill-metrics",title:this.t("Metrics"),componentLoader:function(){return l.e("214").then(l.bind(l,349))}}),[2]})},function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function c(e){t(a,o,i,c,u,"next",e)}function u(e){t(a,o,i,c,u,"throw",e)}c(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(i.prototype,n),i}(i(e.Plugin))}(),g}()});
@@ -11,12 +11,12 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "antd": "5.24.2",
13
13
  "@ant-design/icons": "5.6.1",
14
- "@nocobase/client": "2.1.39",
15
- "@nocobase/client-v2": "2.1.39",
16
- "@nocobase/server": "2.1.39",
14
+ "@nocobase/client": "2.1.45",
15
+ "@nocobase/client-v2": "2.1.45",
16
+ "@nocobase/server": "2.1.45",
17
17
  "dayjs": "1.11.13",
18
- "@nocobase/database": "2.1.39",
19
- "@nocobase/actions": "2.1.39",
20
- "@nocobase/plugin-ai": "2.1.39",
21
- "@nocobase/ai": "2.1.39"
18
+ "@nocobase/database": "2.1.45",
19
+ "@nocobase/actions": "2.1.45",
20
+ "@nocobase/plugin-ai": "2.1.45",
21
+ "@nocobase/ai": "2.1.45"
22
22
  };
@@ -330,6 +330,12 @@ var agent_loop_runs_default = (0, import_database.defineCollection)({
330
330
  type: "json",
331
331
  defaultValue: {}
332
332
  },
333
+ {
334
+ name: "progress",
335
+ type: "json",
336
+ defaultValue: {},
337
+ comment: "Live progress snapshot: { currentPhase, totalPhases, completedPhases, currentStepTitle, currentRole, estimatedMsRemaining }"
338
+ },
333
339
  {
334
340
  name: "userId",
335
341
  type: "bigInt"
@@ -0,0 +1,66 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var skill_metrics_exports = {};
28
+ __export(skill_metrics_exports, {
29
+ default: () => skill_metrics_default
30
+ });
31
+ module.exports = __toCommonJS(skill_metrics_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var skill_metrics_default = (0, import_database.defineCollection)({
34
+ name: "skillMetrics",
35
+ title: "Skill Metrics",
36
+ fields: [
37
+ { name: "id", type: "bigInt", autoIncrement: true, primaryKey: true },
38
+ { name: "skillId", type: "bigInt", allowNull: false },
39
+ {
40
+ name: "skill",
41
+ type: "belongsTo",
42
+ target: "skillDefinitions",
43
+ foreignKey: "skillId",
44
+ onDelete: "CASCADE"
45
+ },
46
+ { name: "employeeUsername", type: "string", length: 100, defaultValue: "" },
47
+ { name: "period", type: "date", allowNull: false, comment: "Daily aggregation date (UTC midnight)." },
48
+ { name: "executions", type: "integer", defaultValue: 0 },
49
+ { name: "successes", type: "integer", defaultValue: 0 },
50
+ { name: "failures", type: "integer", defaultValue: 0 },
51
+ { name: "timeouts", type: "integer", defaultValue: 0 },
52
+ { name: "avgDurationMs", type: "integer", defaultValue: 0 },
53
+ { name: "p95DurationMs", type: "integer", defaultValue: 0 },
54
+ { name: "totalDurationMs", type: "bigInt", defaultValue: 0 },
55
+ { name: "createdAt", type: "date" },
56
+ { name: "updatedAt", type: "date" }
57
+ ],
58
+ indexes: [
59
+ {
60
+ unique: true,
61
+ fields: ["skillId", "employeeUsername", "period"]
62
+ },
63
+ { fields: ["period"] },
64
+ { fields: ["skillId"] }
65
+ ]
66
+ });
@@ -66,6 +66,7 @@ var import_AgentRuntimeLifecycle = require("./services/AgentRuntimeLifecycle");
66
66
  var import_InputSchemaValidator = require("./services/InputSchemaValidator");
67
67
  var import_skill_tool_name = require("./utils/skill-tool-name");
68
68
  var import_ensure_indexes = require("./utils/ensure-indexes");
69
+ var import_RunEventBus = require("./services/RunEventBus");
69
70
  function normalizeOptionalString(value) {
70
71
  return typeof value === "string" ? value.trim() : "";
71
72
  }
@@ -277,7 +278,7 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
277
278
  );
278
279
  this.app.resourceManager.use(
279
280
  async (ctx, next) => {
280
- var _a2, _b2, _c2, _d2, _e, _f;
281
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
281
282
  const { resourceName, actionName } = ctx.action || {};
282
283
  if (resourceName !== "skillDefinitions") {
283
284
  await next();
@@ -330,6 +331,18 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
330
331
  }
331
332
  }
332
333
  await next();
334
+ if (actionName === "update" && values.enabled === false) {
335
+ const tk = (_h = (_g = ctx.action) == null ? void 0 : _g.params) == null ? void 0 : _h.filterByTk;
336
+ if (tk) {
337
+ const skillRecord = await ctx.db.getRepository("skillDefinitions").findOne({ filterByTk: tk });
338
+ if (skillRecord) {
339
+ const toolName = (0, import_skill_tool_name.getSkillToolName)(skillRecord);
340
+ if (toolName) {
341
+ await this.skillHub.skillAccessService.cascadeDisableSkill(toolName);
342
+ }
343
+ }
344
+ }
345
+ }
333
346
  if ((actionName === "list" || actionName === "get") && !(0, import_ctx_utils.isAdminUser)(ctx)) {
334
347
  ctx.body = redactSkillResponse(ctx.body);
335
348
  }
@@ -353,7 +366,7 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
353
366
  (0, import_loop_pattern_context.employeeHarnessResolver)(this),
354
367
  async () => (0, import_loop_pattern_context.worktreeCapability)(this)
355
368
  );
356
- const triggers = new import_LoopTriggerService.LoopTriggerService(this.db, patterns);
369
+ const triggers = new import_LoopTriggerService.LoopTriggerService(this.db, patterns, this.app.log);
357
370
  this.loopScheduler = new import_LoopSchedulerService.LoopSchedulerService(this, patterns, triggers);
358
371
  this.loopWorker = new import_LoopWorkerService.LoopWorkerService(this.app, this.db);
359
372
  this.loopScheduler.install();
@@ -390,6 +403,81 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
390
403
  }
391
404
  }
392
405
  });
406
+ this.app.cronJobManager.addJob({
407
+ cronTime: process.env.SKILL_METRICS_CRON || "0 0 3 * * *",
408
+ onTick: async () => {
409
+ try {
410
+ await this.aggregateSkillMetrics();
411
+ } catch (e) {
412
+ this.app.log.error("[AgentOrchestrator] Skill metrics aggregation job failed", e);
413
+ }
414
+ }
415
+ });
416
+ }
417
+ async aggregateSkillMetrics() {
418
+ var _a, _b, _c, _d;
419
+ const yesterday = new Date(Date.now() - 864e5);
420
+ yesterday.setUTCHours(0, 0, 0, 0);
421
+ const today = new Date(yesterday.getTime() + 864e5);
422
+ const repo = this.db.getRepository("skillExecutions");
423
+ if (!repo) return;
424
+ const rows = await repo.find({
425
+ filter: {
426
+ createdAt: {
427
+ $gte: yesterday.toISOString(),
428
+ $lt: today.toISOString()
429
+ }
430
+ },
431
+ fields: ["skillId", "aiEmployeeUsername", "status", "durationMs"]
432
+ });
433
+ const buckets = /* @__PURE__ */ new Map();
434
+ for (const row of rows) {
435
+ const skillId = String(((_a = row.get) == null ? void 0 : _a.call(row, "skillId")) || "");
436
+ const username = String(((_b = row.get) == null ? void 0 : _b.call(row, "aiEmployeeUsername")) || "");
437
+ const status = String(((_c = row.get) == null ? void 0 : _c.call(row, "status")) || "");
438
+ const durationMs = Number(((_d = row.get) == null ? void 0 : _d.call(row, "durationMs")) || 0);
439
+ if (!skillId) continue;
440
+ const key = `${skillId}:${username}`;
441
+ if (!buckets.has(key)) {
442
+ buckets.set(key, { executions: 0, successes: 0, failures: 0, timeouts: 0, durations: [] });
443
+ }
444
+ const bucket = buckets.get(key) ?? { executions: 0, successes: 0, failures: 0, timeouts: 0, durations: [] };
445
+ bucket.executions += 1;
446
+ if (status === "succeeded") bucket.successes += 1;
447
+ else if (status === "timeout") bucket.timeouts += 1;
448
+ else if (status === "failed") bucket.failures += 1;
449
+ if (durationMs > 0) bucket.durations.push(durationMs);
450
+ }
451
+ const metricsRepo = this.db.getRepository("skillMetrics");
452
+ if (!metricsRepo) return;
453
+ let upserted = 0;
454
+ for (const [key, bucket] of buckets) {
455
+ const firstColon = key.indexOf(":");
456
+ const skillId = key.substring(0, firstColon);
457
+ const employeeUsername = key.substring(firstColon + 1);
458
+ const sortedDurations = [...bucket.durations].sort((a, b) => a - b);
459
+ const p95Index = Math.max(0, Math.ceil(sortedDurations.length * 0.95) - 1);
460
+ const totalDuration = sortedDurations.reduce((sum, d) => sum + d, 0);
461
+ await metricsRepo.updateOrCreate({
462
+ filterKeys: ["skillId", "employeeUsername", "period"],
463
+ values: {
464
+ skillId,
465
+ employeeUsername,
466
+ period: yesterday.toISOString(),
467
+ executions: bucket.executions,
468
+ successes: bucket.successes,
469
+ failures: bucket.failures,
470
+ timeouts: bucket.timeouts,
471
+ avgDurationMs: bucket.durations.length ? Math.round(totalDuration / bucket.durations.length) : 0,
472
+ p95DurationMs: sortedDurations.length > 1 ? sortedDurations[p95Index] : sortedDurations[0] || 0,
473
+ totalDurationMs: totalDuration
474
+ }
475
+ });
476
+ upserted += 1;
477
+ }
478
+ this.app.log.info(
479
+ `[AgentOrchestrator] Skill metrics aggregated for ${yesterday.toISOString().slice(0, 10)}: ${upserted} metric row(s).`
480
+ );
393
481
  }
394
482
  async install() {
395
483
  await this.skillHub.install();
@@ -416,6 +504,7 @@ class PluginAgentOrchestratorServer extends import_server.Plugin {
416
504
  await ((_j = this.loopScheduler) == null ? void 0 : _j.dispose());
417
505
  (_k = this.nativeObserver) == null ? void 0 : _k.uninstall();
418
506
  await this.skillHub.beforeStop();
507
+ (0, import_RunEventBus.resetRunEventBus)();
419
508
  }
420
509
  async handleSyncMessage(message) {
421
510
  var _a, _b;
@@ -33,6 +33,7 @@ var import_LoopRunRepository = require("../services/LoopRunRepository");
33
33
  var import_RunEventBus = require("../services/RunEventBus");
34
34
  var import_resource_helpers = require("./resource-helpers");
35
35
  const POLL_INTERVAL_MS = 1500;
36
+ const KEEPALIVE_INTERVAL_MS = 15e3;
36
37
  function eventId(event) {
37
38
  if (!event || typeof event !== "object") return 0;
38
39
  const id = Number(event.id);
@@ -94,7 +94,7 @@ function registerAgentLoopResource(plugin) {
94
94
  (0, import_loop_pattern_context.employeeHarnessResolver)(plugin),
95
95
  async () => (0, import_loop_pattern_context.worktreeCapability)(plugin)
96
96
  );
97
- const triggers = new import_LoopTriggerService.LoopTriggerService(plugin.db, patterns);
97
+ const triggers = new import_LoopTriggerService.LoopTriggerService(plugin.db, patterns, plugin.app.log);
98
98
  plugin.app.resource({
99
99
  name: "agentLoops",
100
100
  actions: {
@@ -31,10 +31,7 @@ __export(DurableCircuitBreakerService_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(DurableCircuitBreakerService_exports);
33
33
  var import_node_crypto = require("node:crypto");
34
- function read(record, key) {
35
- const model = record;
36
- return typeof model.get === "function" ? model.get(key) : record[key];
37
- }
34
+ var import_record_utils = require("../utils/record-utils");
38
35
  function count(value, label) {
39
36
  if (value === null || value === void 0) return 0;
40
37
  const parsed = Number(value);
@@ -47,8 +44,8 @@ function dateOrNull(value) {
47
44
  return Number.isNaN(date.getTime()) ? null : date;
48
45
  }
49
46
  function snapshot(record) {
50
- const id = Number(read(record, "id"));
51
- const state = read(record, "state");
47
+ const id = Number((0, import_record_utils.read)(record, "id"));
48
+ const state = (0, import_record_utils.read)(record, "state");
52
49
  if (!Number.isSafeInteger(id) || id <= 0) throw new Error("Circuit breaker state has an invalid identifier.");
53
50
  if (state !== "closed" && state !== "open" && state !== "half_open") {
54
51
  throw new Error("Circuit breaker state is invalid.");
@@ -56,11 +53,11 @@ function snapshot(record) {
56
53
  return {
57
54
  id,
58
55
  state,
59
- attempts: count(read(record, "attempts"), "Circuit attempt"),
60
- consecutiveFailures: count(read(record, "consecutiveFailures"), "Circuit consecutive failure"),
61
- errorSignature: typeof read(record, "errorSignature") === "string" ? String(read(record, "errorSignature")) : "",
62
- repeatedErrorCount: count(read(record, "repeatedErrorCount"), "Circuit repeated error"),
63
- retryAt: dateOrNull(read(record, "retryAt"))
56
+ attempts: count((0, import_record_utils.read)(record, "attempts"), "Circuit attempt"),
57
+ consecutiveFailures: count((0, import_record_utils.read)(record, "consecutiveFailures"), "Circuit consecutive failure"),
58
+ errorSignature: typeof (0, import_record_utils.read)(record, "errorSignature") === "string" ? String((0, import_record_utils.read)(record, "errorSignature")) : "",
59
+ repeatedErrorCount: count((0, import_record_utils.read)(record, "repeatedErrorCount"), "Circuit repeated error"),
60
+ retryAt: dateOrNull((0, import_record_utils.read)(record, "retryAt"))
64
61
  };
65
62
  }
66
63
  function normalizeScopeKey(scopeKey) {
@@ -148,7 +145,7 @@ class DurableCircuitBreakerService {
148
145
  });
149
146
  if (!record) return;
150
147
  await repository.update({
151
- filterByTk: read(record, "id"),
148
+ filterByTk: (0, import_record_utils.read)(record, "id"),
152
149
  values: {
153
150
  state: "closed",
154
151
  attempts: 0,
@@ -85,15 +85,20 @@ class ExecutionSpanService {
85
85
  });
86
86
  }
87
87
  }
88
+ function deepGet(obj, path) {
89
+ return path.split(".").reduce((current, key) => {
90
+ if (current && typeof current === "object") return current[key];
91
+ return void 0;
92
+ }, obj);
93
+ }
88
94
  function getOrchestratorTraceContext(ctx) {
89
- var _a, _b, _c, _d;
90
- const requestContext = (ctx == null ? void 0 : ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY]) || ((_a = ctx == null ? void 0 : ctx.state) == null ? void 0 : _a.orchestratorTraceContext) || ((_c = (_b = ctx == null ? void 0 : ctx.runtime) == null ? void 0 : _b.context) == null ? void 0 : _c.orchestratorTraceContext) || null;
95
+ const requestContext = ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY] || deepGet(ctx, "state.orchestratorTraceContext") || deepGet(ctx, "runtime.context.orchestratorTraceContext") || null;
91
96
  const agentContext = (0, import_AgentExecutionContext.getAgentExecutionContext)();
92
97
  if (!requestContext && !agentContext) return null;
93
98
  return {
94
99
  ...agentContext || {},
95
100
  ...requestContext || {},
96
- toolCallId: ((_d = ctx == null ? void 0 : ctx.runtime) == null ? void 0 : _d.toolCallId) || (requestContext == null ? void 0 : requestContext.toolCallId) || (agentContext == null ? void 0 : agentContext.toolCallId)
101
+ toolCallId: deepGet(ctx, "runtime.toolCallId") || (requestContext == null ? void 0 : requestContext.toolCallId) || (agentContext == null ? void 0 : agentContext.toolCallId)
97
102
  };
98
103
  }
99
104
  function setOrchestratorTraceContext(ctx, traceContext) {
@@ -30,10 +30,7 @@ __export(HarnessProfileService_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(HarnessProfileService_exports);
32
32
  var import_HarnessSchema = require("./HarnessSchema");
33
- function read(record, key) {
34
- const model = record;
35
- return typeof model.get === "function" ? model.get(key) : record[key];
36
- }
33
+ var import_record_utils = require("../utils/record-utils");
37
34
  function positiveId(value, label) {
38
35
  const parsed = typeof value === "number" ? value : Number(value);
39
36
  if (!Number.isSafeInteger(parsed) || parsed <= 0) {
@@ -43,14 +40,14 @@ function positiveId(value, label) {
43
40
  }
44
41
  function versionRecord(record) {
45
42
  return {
46
- id: positiveId(read(record, "id"), "Harness profile version id"),
47
- profileId: positiveId(read(record, "profileId"), "Harness profile id"),
48
- version: positiveId(read(record, "version"), "Harness profile version"),
49
- schemaVersion: positiveId(read(record, "schemaVersion"), "Harness schema version"),
50
- status: read(record, "status") === "published" ? "published" : "draft",
51
- settings: (0, import_HarnessSchema.parseHarnessSettings)(read(record, "settings")),
52
- publishedById: read(record, "publishedById") || null,
53
- publishedAt: read(record, "publishedAt") || null
43
+ id: positiveId((0, import_record_utils.read)(record, "id"), "Harness profile version id"),
44
+ profileId: positiveId((0, import_record_utils.read)(record, "profileId"), "Harness profile id"),
45
+ version: positiveId((0, import_record_utils.read)(record, "version"), "Harness profile version"),
46
+ schemaVersion: positiveId((0, import_record_utils.read)(record, "schemaVersion"), "Harness schema version"),
47
+ status: (0, import_record_utils.read)(record, "status") === "published" ? "published" : "draft",
48
+ settings: (0, import_HarnessSchema.parseHarnessSettings)((0, import_record_utils.read)(record, "settings")),
49
+ publishedById: (0, import_record_utils.read)(record, "publishedById") || null,
50
+ publishedAt: (0, import_record_utils.read)(record, "publishedAt") || null
54
51
  };
55
52
  }
56
53
  class HarnessProfileService {
@@ -72,7 +69,7 @@ class HarnessProfileService {
72
69
  sort: ["-version"],
73
70
  transaction: active
74
71
  });
75
- const nextVersion = latest ? positiveId(read(latest, "version"), "Harness profile version") + 1 : 1;
72
+ const nextVersion = latest ? positiveId((0, import_record_utils.read)(latest, "version"), "Harness profile version") + 1 : 1;
76
73
  const draft = await versions.create({
77
74
  values: {
78
75
  profileId,
@@ -101,14 +98,14 @@ class HarnessProfileService {
101
98
  sort: ["-version"],
102
99
  transaction
103
100
  });
104
- if (latest && read(latest, "status") !== "published") {
105
- await versions.update({ filterByTk: read(latest, "id"), values: { settings }, transaction });
106
- const updated = await versions.findOne({ filterByTk: read(latest, "id"), transaction });
107
- if (!updated) throw new Error(`Harness profile version ${read(latest, "id")} was not found after update.`);
101
+ if (latest && (0, import_record_utils.read)(latest, "status") !== "published") {
102
+ await versions.update({ filterByTk: (0, import_record_utils.read)(latest, "id"), values: { settings }, transaction });
103
+ const updated = await versions.findOne({ filterByTk: (0, import_record_utils.read)(latest, "id"), transaction });
104
+ if (!updated) throw new Error(`Harness profile version ${(0, import_record_utils.read)(latest, "id")} was not found after update.`);
108
105
  return versionRecord(updated);
109
106
  }
110
- const nextVersion = latest ? positiveId(read(latest, "version"), "Harness profile version") + 1 : 1;
111
- const schemaVersion = latest ? positiveId(read(latest, "schemaVersion") || 1, "Harness schema version") : 1;
107
+ const nextVersion = latest ? positiveId((0, import_record_utils.read)(latest, "version"), "Harness profile version") + 1 : 1;
108
+ const schemaVersion = latest ? positiveId((0, import_record_utils.read)(latest, "schemaVersion") || 1, "Harness schema version") : 1;
112
109
  const draft = await versions.create({
113
110
  values: {
114
111
  profileId,
@@ -128,7 +125,7 @@ class HarnessProfileService {
128
125
  const versions = this.database.getRepository("agentHarnessProfileVersions");
129
126
  const version = await versions.findOne({ filterByTk: id });
130
127
  if (!version) throw new Error(`Harness profile version ${id} was not found.`);
131
- if (read(version, "status") !== "draft") {
128
+ if ((0, import_record_utils.read)(version, "status") !== "draft") {
132
129
  throw new Error("Published Harness profile versions are immutable.");
133
130
  }
134
131
  await versions.update({ filterByTk: id, values: { settings: parsedSettings } });
@@ -142,14 +139,14 @@ class HarnessProfileService {
142
139
  const versions = this.database.getRepository("agentHarnessProfileVersions");
143
140
  const candidate = await versions.findOne({ filterByTk: id, transaction: active });
144
141
  if (!candidate) throw new Error(`Harness profile version ${id} was not found.`);
145
- const profileId = positiveId(read(candidate, "profileId"), "Harness profile id");
142
+ const profileId = positiveId((0, import_record_utils.read)(candidate, "profileId"), "Harness profile id");
146
143
  await this.lockProfile(profileId, active);
147
144
  const current = await versions.findOne({ filterByTk: id, transaction: active });
148
145
  if (!current) throw new Error(`Harness profile version ${id} was not found.`);
149
- if (read(current, "status") === "published") {
146
+ if ((0, import_record_utils.read)(current, "status") === "published") {
150
147
  return versionRecord(current);
151
148
  }
152
- const settings = (0, import_HarnessSchema.parseHarnessSettings)(read(current, "settings"));
149
+ const settings = (0, import_HarnessSchema.parseHarnessSettings)((0, import_record_utils.read)(current, "settings"));
153
150
  const now = /* @__PURE__ */ new Date();
154
151
  await versions.update({
155
152
  filterByTk: id,
@@ -165,7 +162,7 @@ class HarnessProfileService {
165
162
  filterByTk: profileId,
166
163
  values: {
167
164
  currentVersionId: id,
168
- schemaVersion: positiveId(read(current, "schemaVersion"), "Harness schema version")
165
+ schemaVersion: positiveId((0, import_record_utils.read)(current, "schemaVersion"), "Harness schema version")
169
166
  },
170
167
  transaction: active
171
168
  });
@@ -192,7 +189,7 @@ class HarnessProfileService {
192
189
  },
193
190
  transaction
194
191
  });
195
- const profileId = positiveId(read(profile, "id"), "Harness profile id");
192
+ const profileId = positiveId((0, import_record_utils.read)(profile, "id"), "Harness profile id");
196
193
  const draft = await this.createDraft({ profileId, settings }, transaction);
197
194
  const published = await this.publish(draft.id, input.publishedById, transaction);
198
195
  const created = await this.database.getRepository("agentHarnessProfiles").findOne({
@@ -210,7 +207,7 @@ class HarnessProfileService {
210
207
  filter: { tag: normalizedTag, enabled: true }
211
208
  });
212
209
  if (!profile) return null;
213
- const currentVersionId = Number(read(profile, "currentVersionId"));
210
+ const currentVersionId = Number((0, import_record_utils.read)(profile, "currentVersionId"));
214
211
  if (!Number.isSafeInteger(currentVersionId) || currentVersionId <= 0) return null;
215
212
  const version = await this.database.getRepository("agentHarnessProfileVersions").findOne({
216
213
  filter: { id: currentVersionId, status: "published" }