@dnotifier-realtime/dnotifier 1.1.30 → 1.1.31

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/agent-runtime/backendClient.js +1 -1
  2. package/dist/agent-runtime/descriptors.js +1 -1
  3. package/dist/agent-runtime/errors.js +1 -1
  4. package/dist/agent-runtime/ids.js +1 -1
  5. package/dist/agent-runtime/index.d.ts +1 -0
  6. package/dist/agent-runtime/index.js +1 -1
  7. package/dist/agent-runtime/localCompletions.js +1 -1
  8. package/dist/agent-runtime/mcp/client.js +1 -1
  9. package/dist/agent-runtime/mcp/registry.js +1 -1
  10. package/dist/agent-runtime/middleware.d.ts +65 -0
  11. package/dist/agent-runtime/middleware.js +1 -0
  12. package/dist/agent-runtime/observability.js +1 -1
  13. package/dist/agent-runtime/permissions.js +1 -1
  14. package/dist/agent-runtime/runtime.d.ts +1 -0
  15. package/dist/agent-runtime/runtime.js +1 -1
  16. package/dist/agent-runtime/schema.js +1 -1
  17. package/dist/agent-runtime/toolRegistry.js +1 -1
  18. package/dist/cjs/dnotifier.js +1 -1
  19. package/dist/cjs/providers/openai.js +1 -1
  20. package/dist/cjs/transport/httpTransport.js +1 -1
  21. package/dist/cjs/transport/websocketTransport.js +1 -1
  22. package/dist/cjs/utils/buffer.js +1 -1
  23. package/dist/cjs/utils/frame.js +1 -1
  24. package/dist/cjs/utils/id.js +1 -1
  25. package/dist/cjs/utils/payload.js +1 -1
  26. package/dist/config/endpoints.js +1 -1
  27. package/dist/dnotifier.cjs +7 -7
  28. package/dist/dnotifier.d.ts +2 -7
  29. package/dist/dnotifier.js +1 -1
  30. package/dist/providers/openai.js +1 -1
  31. package/dist/transport/httpTransport.js +1 -1
  32. package/dist/transport/websocketTransport.js +1 -1
  33. package/dist/utils/buffer.js +1 -1
  34. package/dist/utils/frame.js +1 -1
  35. package/dist/utils/id.js +1 -1
  36. package/dist/utils/logs.js +1 -1
  37. package/dist/utils/payload.js +1 -1
  38. package/dist/workflow/agent.d.ts +6 -2
  39. package/dist/workflow/agent.js +1 -1
  40. package/dist/workflow/capabilities.js +1 -1
  41. package/dist/workflow/context.js +1 -1
  42. package/dist/workflow/errors.js +1 -1
  43. package/dist/workflow/graphParents.js +1 -1
  44. package/dist/workflow/ids.js +1 -1
  45. package/dist/workflow/jsonPayload.js +1 -1
  46. package/dist/workflow/mockObservabilityClient.js +1 -1
  47. package/dist/workflow/observability.js +1 -1
  48. package/dist/workflow/remoteAgentClient.js +1 -1
  49. package/dist/workflow/remoteAgentProtocol.js +1 -1
  50. package/dist/workflow/runner.d.ts +1 -1
  51. package/dist/workflow/runner.js +1 -1
  52. package/dist/workflow/stepTypes.js +1 -1
  53. package/dist/workflow/workflow.d.ts +3 -1
  54. package/dist/workflow/workflow.js +1 -1
  55. package/dist/workflow/workflowObservabilityClient.js +1 -1
  56. package/package.json +1 -1
@@ -1 +1 @@
1
- export function randomUUID(){const _0x55ada4='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x55ada4&&'function'==typeof _0x55ada4['randomUUID'])return _0x55ada4['randomUUID']();if(_0x55ada4&&_0x55ada4['getRandomValues']){const _0x227f48=new Uint8Array(0x10);_0x55ada4['getRandomValues'](_0x227f48),_0x227f48[0x6]=0xf&_0x227f48[0x6]|0x40,_0x227f48[0x8]=0x3f&_0x227f48[0x8]|0x80;const _0x4e3614=[..._0x227f48]['map'](_0x4b5340=>_0x4b5340['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x4e3614['slice'](0x0,0x8)+'-'+_0x4e3614['slice'](0x8,0xc)+'-'+_0x4e3614['slice'](0xc,0x10)+'-'+_0x4e3614['slice'](0x10,0x14)+'-'+_0x4e3614['slice'](0x14);}return'id_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function shortId(_0x51c76d){return _0x51c76d+'_'+randomUUID()['replace'](/-/g,'')['slice'](0x0,0xc);}
1
+ export function randomUUID(){const _0x3561c6='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x3561c6&&'function'==typeof _0x3561c6['randomUUID'])return _0x3561c6['randomUUID']();if(_0x3561c6&&_0x3561c6['getRandomValues']){const _0x240de3=new Uint8Array(0x10);_0x3561c6['getRandomValues'](_0x240de3),_0x240de3[0x6]=0xf&_0x240de3[0x6]|0x40,_0x240de3[0x8]=0x3f&_0x240de3[0x8]|0x80;const _0x394981=[..._0x240de3]['map'](_0x5a925b=>_0x5a925b['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x394981['slice'](0x0,0x8)+'-'+_0x394981['slice'](0x8,0xc)+'-'+_0x394981['slice'](0xc,0x10)+'-'+_0x394981['slice'](0x10,0x14)+'-'+_0x394981['slice'](0x14);}return'id_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function shortId(_0x14438c){return _0x14438c+'_'+randomUUID()['replace'](/-/g,'')['slice'](0x0,0xc);}
@@ -1 +1 @@
1
- export function toJsonColumn(_0x7171dd){if(null==_0x7171dd)return null;if('string'==typeof _0x7171dd){const _0x3d64a1=_0x7171dd['trim']();if(''===_0x3d64a1)return{};if(_0x3d64a1['startsWith']('{')||_0x3d64a1['startsWith']('['))try{return JSON['parse'](_0x3d64a1);}catch{return{'text':_0x7171dd};}return{'text':_0x7171dd};}if('number'==typeof _0x7171dd||'boolean'==typeof _0x7171dd)return _0x7171dd;try{return JSON['parse'](JSON['stringify'](_0x7171dd,(_0xe6bec0,_0x37baed)=>'bigint'==typeof _0x37baed?_0x37baed['toString']():_0x37baed));}catch{return{'text':String(_0x7171dd)};}}export function setJsonColumn(_0x243ac3,_0x1589fe,_0x57350c){const _0x9b7890=toJsonColumn(_0x57350c);null!==_0x9b7890&&(_0x243ac3[_0x1589fe]=_0x9b7890);}
1
+ export function toJsonColumn(_0x3f98e8){if(null==_0x3f98e8)return null;if('string'==typeof _0x3f98e8){const _0x48e1e6=_0x3f98e8['trim']();if(''===_0x48e1e6)return{};if(_0x48e1e6['startsWith']('{')||_0x48e1e6['startsWith']('['))try{return JSON['parse'](_0x48e1e6);}catch{return{'text':_0x3f98e8};}return{'text':_0x3f98e8};}if('number'==typeof _0x3f98e8||'boolean'==typeof _0x3f98e8)return _0x3f98e8;try{return JSON['parse'](JSON['stringify'](_0x3f98e8,(_0x406cee,_0x4267d7)=>'bigint'==typeof _0x4267d7?_0x4267d7['toString']():_0x4267d7));}catch{return{'text':String(_0x3f98e8)};}}export function setJsonColumn(_0x1563b8,_0x160561,_0x5ce839){const _0x1b3eac=toJsonColumn(_0x5ce839);null!==_0x1b3eac&&(_0x1563b8[_0x160561]=_0x1b3eac);}
@@ -1 +1 @@
1
- import{HttpTransport}from'../transport/httpTransport.js';import{DNotifierEndpoints}from'../config/endpoints.js';import{shortId}from'./ids.js';const globalMockStore={'workflows':new Map(),'executions':new Map(),'stepsByExecution':new Map(),'errorCountByWorkflow':new Map()};export class MockWorkflowObservabilityClient{constructor({appId:_0x53fb50=null,token:_0x24aabc=null,httpEnabled:_0x118541=!0x1}={}){this['appId']=_0x53fb50,this['token']=_0x24aabc,this['httpEnabled']=Boolean(_0x118541),this['workflows']=globalMockStore['workflows'],this['executions']=globalMockStore['executions'],this['stepsByExecution']=globalMockStore['stepsByExecution'],this['errorCountByWorkflow']=globalMockStore['errorCountByWorkflow'];}['configure']({appId:_0x433c11,token:_0x2759d1}={}){void 0x0!==_0x433c11&&(this['appId']=_0x433c11),void 0x0!==_0x2759d1&&(this['token']=_0x2759d1);}['_transport'](_0x3ec44d){const _0x21509f=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x3ec44d,'headers':_0x21509f});}async['_maybeHttp'](_0x4efaa1,_0x1019d4,_0x552415){var _0x46dc3d;if(this['httpEnabled'])try{const _0x1901b6=this['_transport'](_0x1019d4);'POST'===_0x4efaa1&&await _0x1901b6['send'](_0x552415);}catch(_0x5bd00b){console['warn']('[WorkflowObservability]\x20mock\x20HTTP\x20failed:',null!==(_0x46dc3d=null==_0x5bd00b?void 0x0:_0x5bd00b['message'])&&void 0x0!==_0x46dc3d?_0x46dc3d:_0x5bd00b);}}async['registerWorkflow'](_0x5535be){var _0x49132a;const _0x278478=(null!==(_0x49132a=this['appId'])&&void 0x0!==_0x49132a?_0x49132a:'app')+':'+_0x5535be['workflowId'];return this['workflows']['has'](_0x278478)||this['workflows']['set'](_0x278478,{..._0x5535be,'registeredAt':new Date()['toISOString']()}),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockRegisterUrl'],_0x5535be),{'ok':!0x0};}async['createExecution'](_0x1f9abe){var _0x2865c8;const _0x3b6e9c=null!==(_0x2865c8=_0x1f9abe['id'])&&void 0x0!==_0x2865c8?_0x2865c8:shortId('exec'),_0x25d982={..._0x1f9abe,'id':_0x3b6e9c,'status':'in_progress','stepCount':0x0,'steps':[]};return this['executions']['set'](_0x3b6e9c,_0x25d982),this['stepsByExecution']['set'](_0x3b6e9c,[]),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionsUrl'],_0x25d982),{'executionId':_0x3b6e9c,'record':_0x25d982};}async['updateExecution'](_0x222e3b,_0x4a03fc){var _0x515603;const _0x3243c9=this['executions']['get'](_0x222e3b);if(!_0x3243c9)return{'ok':!0x1};const _0x20ab37={..._0x3243c9,..._0x4a03fc};if(this['executions']['set'](_0x222e3b,_0x20ab37),'error'===_0x4a03fc['status']&&_0x20ab37['workflowId']){const _0x4b750e=_0x20ab37['workflowId'];this['errorCountByWorkflow']['set'](_0x4b750e,(null!==(_0x515603=this['errorCountByWorkflow']['get'](_0x4b750e))&&void 0x0!==_0x515603?_0x515603:0x0)+0x1);}return await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionUrl'](_0x222e3b),_0x20ab37),{'ok':!0x0,'record':_0x20ab37};}async['addStep'](_0x2a5e5c,_0x3df5b7){var _0x1777d4,_0x345abd;const _0x3f303c=null!==(_0x1777d4=this['stepsByExecution']['get'](_0x2a5e5c))&&void 0x0!==_0x1777d4?_0x1777d4:[];_0x3f303c['push'](_0x3df5b7),this['stepsByExecution']['set'](_0x2a5e5c,_0x3f303c);const _0x265ed8=this['executions']['get'](_0x2a5e5c);return _0x265ed8&&(_0x265ed8['stepCount']=_0x3f303c['length'],_0x265ed8['steps']=_0x3f303c,this['executions']['set'](_0x2a5e5c,_0x265ed8)),'error'===_0x3df5b7['status']&&(null==_0x265ed8?void 0x0:_0x265ed8['workflowId'])&&this['errorCountByWorkflow']['set'](_0x265ed8['workflowId'],(null!==(_0x345abd=this['errorCountByWorkflow']['get'](_0x265ed8['workflowId']))&&void 0x0!==_0x345abd?_0x345abd:0x0)+0x1),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockStepsUrl'](_0x2a5e5c),_0x3df5b7),{'ok':!0x0};}['getDashboardSnapshot'](){return{'totalWorkflows':this['workflows']['size'],'executions':[...this['executions']['values']()],'stepsByExecution':Object['fromEntries'](this['stepsByExecution']),'errorCountByWorkflow':Object['fromEntries'](this['errorCountByWorkflow'])};}}
1
+ import{HttpTransport}from'../transport/httpTransport.js';import{DNotifierEndpoints}from'../config/endpoints.js';import{shortId}from'./ids.js';const globalMockStore={'workflows':new Map(),'executions':new Map(),'stepsByExecution':new Map(),'errorCountByWorkflow':new Map()};export class MockWorkflowObservabilityClient{constructor({appId:_0x57e794=null,token:_0x33ffbc=null,httpEnabled:_0x3ae954=!0x1}={}){this['appId']=_0x57e794,this['token']=_0x33ffbc,this['httpEnabled']=Boolean(_0x3ae954),this['workflows']=globalMockStore['workflows'],this['executions']=globalMockStore['executions'],this['stepsByExecution']=globalMockStore['stepsByExecution'],this['errorCountByWorkflow']=globalMockStore['errorCountByWorkflow'];}['configure']({appId:_0x35045e,token:_0x2917a8}={}){void 0x0!==_0x35045e&&(this['appId']=_0x35045e),void 0x0!==_0x2917a8&&(this['token']=_0x2917a8);}['_transport'](_0x8b4cba){const _0x47b1bb=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x8b4cba,'headers':_0x47b1bb});}async['_maybeHttp'](_0x401d9b,_0x1e9ee0,_0x28aa23){var _0xb22fe;if(this['httpEnabled'])try{const _0x22a761=this['_transport'](_0x1e9ee0);'POST'===_0x401d9b&&await _0x22a761['send'](_0x28aa23);}catch(_0x5bf634){console['warn']('[WorkflowObservability]\x20mock\x20HTTP\x20failed:',null!==(_0xb22fe=null==_0x5bf634?void 0x0:_0x5bf634['message'])&&void 0x0!==_0xb22fe?_0xb22fe:_0x5bf634);}}async['registerWorkflow'](_0x3a0e63){var _0x12fc5b;const _0x9d972c=(null!==(_0x12fc5b=this['appId'])&&void 0x0!==_0x12fc5b?_0x12fc5b:'app')+':'+_0x3a0e63['workflowId'];return this['workflows']['has'](_0x9d972c)||this['workflows']['set'](_0x9d972c,{..._0x3a0e63,'registeredAt':new Date()['toISOString']()}),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockRegisterUrl'],_0x3a0e63),{'ok':!0x0};}async['createExecution'](_0x20e21a){var _0x22a42b;const _0x3ac2ad=null!==(_0x22a42b=_0x20e21a['id'])&&void 0x0!==_0x22a42b?_0x22a42b:shortId('exec'),_0x2826b4={..._0x20e21a,'id':_0x3ac2ad,'status':'in_progress','stepCount':0x0,'steps':[]};return this['executions']['set'](_0x3ac2ad,_0x2826b4),this['stepsByExecution']['set'](_0x3ac2ad,[]),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionsUrl'],_0x2826b4),{'executionId':_0x3ac2ad,'record':_0x2826b4};}async['updateExecution'](_0x47a584,_0x5f504e){var _0x44a9cb;const _0x72bed2=this['executions']['get'](_0x47a584);if(!_0x72bed2)return{'ok':!0x1};const _0x2b1ac7={..._0x72bed2,..._0x5f504e};if(this['executions']['set'](_0x47a584,_0x2b1ac7),'error'===_0x5f504e['status']&&_0x2b1ac7['workflowId']){const _0x20640a=_0x2b1ac7['workflowId'];this['errorCountByWorkflow']['set'](_0x20640a,(null!==(_0x44a9cb=this['errorCountByWorkflow']['get'](_0x20640a))&&void 0x0!==_0x44a9cb?_0x44a9cb:0x0)+0x1);}return await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionUrl'](_0x47a584),_0x2b1ac7),{'ok':!0x0,'record':_0x2b1ac7};}async['addStep'](_0x58b1de,_0x4df8da){var _0x37efc7,_0x5349e6;const _0x43d8fd=null!==(_0x37efc7=this['stepsByExecution']['get'](_0x58b1de))&&void 0x0!==_0x37efc7?_0x37efc7:[];_0x43d8fd['push'](_0x4df8da),this['stepsByExecution']['set'](_0x58b1de,_0x43d8fd);const _0x3e9948=this['executions']['get'](_0x58b1de);return _0x3e9948&&(_0x3e9948['stepCount']=_0x43d8fd['length'],_0x3e9948['steps']=_0x43d8fd,this['executions']['set'](_0x58b1de,_0x3e9948)),'error'===_0x4df8da['status']&&(null==_0x3e9948?void 0x0:_0x3e9948['workflowId'])&&this['errorCountByWorkflow']['set'](_0x3e9948['workflowId'],(null!==(_0x5349e6=this['errorCountByWorkflow']['get'](_0x3e9948['workflowId']))&&void 0x0!==_0x5349e6?_0x5349e6:0x0)+0x1),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockStepsUrl'](_0x58b1de),_0x4df8da),{'ok':!0x0};}['getDashboardSnapshot'](){return{'totalWorkflows':this['workflows']['size'],'executions':[...this['executions']['values']()],'stepsByExecution':Object['fromEntries'](this['stepsByExecution']),'errorCountByWorkflow':Object['fromEntries'](this['errorCountByWorkflow'])};}}
@@ -1 +1 @@
1
- import{WorkflowObservabilityClient}from'./workflowObservabilityClient.js';import{shortId}from'./ids.js';import{resolveGraphParentStepId}from'./graphParents.js';import{resolveStepType}from'./stepTypes.js';export class WorkflowObservability{constructor({appId:_0x3ac2a1,token:_0x5bab0f=null,client:_0x49c01c,appendOnly:_0x4fa5a2=!0x1}){this['appId']=_0x3ac2a1,this['token']=_0x5bab0f,this['client']=null!=_0x49c01c?_0x49c01c:new WorkflowObservabilityClient({'appId':_0x3ac2a1,'token':_0x5bab0f}),this['client']['configure']({'appId':_0x3ac2a1,'token':_0x5bab0f}),this['_registeredWorkflowNames']=new Set(),this['_stepCounter']=0x0,this['_appendOnly']=Boolean(_0x4fa5a2);}['allocateStepId'](){return shortId('step');}async['registerWorkflow'](_0x3bdef5){var _0x217a4a;if(!this['_registeredWorkflowNames']['has'](_0x3bdef5['name'])){this['_registeredWorkflowNames']['add'](_0x3bdef5['name']);try{await this['client']['registerWorkflow']({'appId':this['appId'],'workflowId':_0x3bdef5['name'],'name':_0x3bdef5['name'],'description':null!==(_0x217a4a=_0x3bdef5['description'])&&void 0x0!==_0x217a4a?_0x217a4a:null});}catch{}}}async['startExecution'](_0x2513b5){var _0x20d5ad;if(this['_appendOnly'])throw new Error('startExecution\x20is\x20not\x20allowed\x20in\x20append-only\x20workflow\x20observability\x20mode');const _0xe26bd9=shortId('exec'),_0x5804cc='number'==typeof _0x2513b5['startedAtMs']&&Number['isFinite'](_0x2513b5['startedAtMs'])?_0x2513b5['startedAtMs']:Date['now'](),_0x514258='string'==typeof _0x2513b5['startedAt']&&_0x2513b5['startedAt']['trim']()?_0x2513b5['startedAt']:new Date(_0x5804cc)['toISOString']();try{await this['client']['createExecution']({'id':_0xe26bd9,'appId':this['appId'],'workflowId':_0x2513b5['workflowId'],'userId':_0x2513b5['userId'],'input':null!==(_0x20d5ad=_0x2513b5['input'])&&void 0x0!==_0x20d5ad?_0x20d5ad:null,'startedAt':_0x514258});}catch{}return this['_stepCounter']=0x0,{'executionId':_0xe26bd9,'startedAt':_0x514258,'startedAtMs':_0x5804cc};}async['recordStep'](_0x24e2b7,_0x54f63b){var _0x455aef,_0x125a28,_0x325226,_0x144755,_0x2c0be3,_0x3d9f5f,_0x1d1f02,_0x544581,_0x5ebdbd;if(!_0x24e2b7)return null;this['_stepCounter']+=0x1;const _0x2ae537=null!==(_0x455aef=_0x54f63b['id'])&&void 0x0!==_0x455aef?_0x455aef:this['allocateStepId'](),_0x1b8cd8=resolveStepType(_0x54f63b),_0x42424c=null!==(_0x144755=null!==(_0x325226=null!==(_0x125a28=_0x54f63b['agentName'])&&void 0x0!==_0x125a28?_0x125a28:_0x54f63b['kind'])&&void 0x0!==_0x325226?_0x325226:_0x54f63b['apiName'])&&void 0x0!==_0x144755?_0x144755:null,_0x4023db=resolveGraphParentStepId(_0x54f63b),_0x263cd1={..._0x54f63b,'id':_0x2ae537,'executionId':_0x24e2b7,'executedAt':null!==(_0x2c0be3=_0x54f63b['executedAt'])&&void 0x0!==_0x2c0be3?_0x2c0be3:new Date()['toISOString'](),'apiName':null!==(_0x3d9f5f=_0x54f63b['apiName'])&&void 0x0!==_0x3d9f5f?_0x3d9f5f:null,'agentName':null!==(_0x1d1f02=_0x54f63b['agentName'])&&void 0x0!==_0x1d1f02?_0x1d1f02:null,'kind':_0x42424c,'type':_0x1b8cd8,'step_type':_0x1b8cd8,'parentStepId':_0x4023db,'siblingIndex':null!==(_0x544581=_0x54f63b['siblingIndex'])&&void 0x0!==_0x544581?_0x544581:null,'branchKey':null!==(_0x5ebdbd=_0x54f63b['branchKey'])&&void 0x0!==_0x5ebdbd?_0x5ebdbd:null};delete _0x263cd1['dependsOn'],delete _0x263cd1['parentStepIds'];try{await this['client']['addStep'](_0x24e2b7,_0x263cd1);}catch{}return _0x263cd1;}async['completeExecution'](_0xfaf603){var _0x75359f,_0x57ddf3;if(!this['_appendOnly']&&_0xfaf603['executionId'])try{await this['client']['updateExecution'](_0xfaf603['executionId'],{'status':_0xfaf603['status'],'endedAt':_0xfaf603['endedAt'],'durationMs':_0xfaf603['durationMs'],'stepCount':_0xfaf603['stepCount'],'error':null!==(_0x75359f=_0xfaf603['error'])&&void 0x0!==_0x75359f?_0x75359f:null,'result':null!==(_0x57ddf3=_0xfaf603['result'])&&void 0x0!==_0x57ddf3?_0x57ddf3:null});}catch{}}['getStepCount'](){return this['_stepCounter'];}}export function createWorkflowObservability(_0x2a4c8a){return new WorkflowObservability(_0x2a4c8a);}
1
+ import{WorkflowObservabilityClient}from'./workflowObservabilityClient.js';import{shortId}from'./ids.js';import{resolveGraphParentStepId}from'./graphParents.js';import{resolveStepType}from'./stepTypes.js';export class WorkflowObservability{constructor({appId:_0x4faea0,token:_0x1a83b5=null,client:_0x4d2ed9,appendOnly:_0x26af6e=!0x1}){this['appId']=_0x4faea0,this['token']=_0x1a83b5,this['client']=null!=_0x4d2ed9?_0x4d2ed9:new WorkflowObservabilityClient({'appId':_0x4faea0,'token':_0x1a83b5}),this['client']['configure']({'appId':_0x4faea0,'token':_0x1a83b5}),this['_registeredWorkflowNames']=new Set(),this['_stepCounter']=0x0,this['_appendOnly']=Boolean(_0x26af6e);}['allocateStepId'](){return shortId('step');}async['registerWorkflow'](_0xfec6a6){var _0x426fa0;if(!this['_registeredWorkflowNames']['has'](_0xfec6a6['name'])){this['_registeredWorkflowNames']['add'](_0xfec6a6['name']);try{await this['client']['registerWorkflow']({'appId':this['appId'],'workflowId':_0xfec6a6['name'],'name':_0xfec6a6['name'],'description':null!==(_0x426fa0=_0xfec6a6['description'])&&void 0x0!==_0x426fa0?_0x426fa0:null});}catch{}}}async['startExecution'](_0xb8cb09){var _0x99534f;if(this['_appendOnly'])throw new Error('startExecution\x20is\x20not\x20allowed\x20in\x20append-only\x20workflow\x20observability\x20mode');const _0x3c663c=shortId('exec'),_0x4c6f59='number'==typeof _0xb8cb09['startedAtMs']&&Number['isFinite'](_0xb8cb09['startedAtMs'])?_0xb8cb09['startedAtMs']:Date['now'](),_0x57c56a='string'==typeof _0xb8cb09['startedAt']&&_0xb8cb09['startedAt']['trim']()?_0xb8cb09['startedAt']:new Date(_0x4c6f59)['toISOString']();try{await this['client']['createExecution']({'id':_0x3c663c,'appId':this['appId'],'workflowId':_0xb8cb09['workflowId'],'userId':_0xb8cb09['userId'],'input':null!==(_0x99534f=_0xb8cb09['input'])&&void 0x0!==_0x99534f?_0x99534f:null,'startedAt':_0x57c56a});}catch{}return this['_stepCounter']=0x0,{'executionId':_0x3c663c,'startedAt':_0x57c56a,'startedAtMs':_0x4c6f59};}async['recordStep'](_0x1fdf9b,_0x2fc291){var _0x1f563d,_0x3ba704,_0x4cfa52,_0x4551e4,_0x3a02ed,_0x432484,_0x340c57,_0x260f0e,_0x138ad4;if(!_0x1fdf9b)return null;this['_stepCounter']+=0x1;const _0x1b697d=null!==(_0x1f563d=_0x2fc291['id'])&&void 0x0!==_0x1f563d?_0x1f563d:this['allocateStepId'](),_0x10f821=resolveStepType(_0x2fc291),_0x50bd97=null!==(_0x4551e4=null!==(_0x4cfa52=null!==(_0x3ba704=_0x2fc291['agentName'])&&void 0x0!==_0x3ba704?_0x3ba704:_0x2fc291['kind'])&&void 0x0!==_0x4cfa52?_0x4cfa52:_0x2fc291['apiName'])&&void 0x0!==_0x4551e4?_0x4551e4:null,_0x3ddc4c=resolveGraphParentStepId(_0x2fc291),_0x21cc7e={..._0x2fc291,'id':_0x1b697d,'executionId':_0x1fdf9b,'executedAt':null!==(_0x3a02ed=_0x2fc291['executedAt'])&&void 0x0!==_0x3a02ed?_0x3a02ed:new Date()['toISOString'](),'apiName':null!==(_0x432484=_0x2fc291['apiName'])&&void 0x0!==_0x432484?_0x432484:null,'agentName':null!==(_0x340c57=_0x2fc291['agentName'])&&void 0x0!==_0x340c57?_0x340c57:null,'kind':_0x50bd97,'type':_0x10f821,'step_type':_0x10f821,'parentStepId':_0x3ddc4c,'siblingIndex':null!==(_0x260f0e=_0x2fc291['siblingIndex'])&&void 0x0!==_0x260f0e?_0x260f0e:null,'branchKey':null!==(_0x138ad4=_0x2fc291['branchKey'])&&void 0x0!==_0x138ad4?_0x138ad4:null};delete _0x21cc7e['dependsOn'],delete _0x21cc7e['parentStepIds'];try{await this['client']['addStep'](_0x1fdf9b,_0x21cc7e);}catch{}return _0x21cc7e;}async['completeExecution'](_0x2033c2){var _0x429ff3,_0x412a61;if(!this['_appendOnly']&&_0x2033c2['executionId'])try{await this['client']['updateExecution'](_0x2033c2['executionId'],{'status':_0x2033c2['status'],'endedAt':_0x2033c2['endedAt'],'durationMs':_0x2033c2['durationMs'],'stepCount':_0x2033c2['stepCount'],'error':null!==(_0x429ff3=_0x2033c2['error'])&&void 0x0!==_0x429ff3?_0x429ff3:null,'result':null!==(_0x412a61=_0x2033c2['result'])&&void 0x0!==_0x412a61?_0x412a61:null});}catch{}}['getStepCount'](){return this['_stepCounter'];}}export function createWorkflowObservability(_0x16206a){return new WorkflowObservability(_0x16206a);}
@@ -1 +1 @@
1
- import{WorkflowError}from'./errors.js';import{createErrorEnvelope,createInvokeEnvelope,createResultEnvelope,REMOTE_AGENT_OP}from'./remoteAgentProtocol.js';const DEFAULT_TIMEOUT_MS=0x1d4c0;function correlationId(){const _0x5a46db='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x5a46db&&'function'==typeof _0x5a46db['randomUUID'])return _0x5a46db['randomUUID']();if(_0x5a46db&&_0x5a46db['getRandomValues']){const _0x1ace1b=new Uint8Array(0x10);_0x5a46db['getRandomValues'](_0x1ace1b),_0x1ace1b[0x6]=0xf&_0x1ace1b[0x6]|0x40,_0x1ace1b[0x8]=0x3f&_0x1ace1b[0x8]|0x80;const _0x2a0196=[..._0x1ace1b]['map'](_0x2f7615=>_0x2f7615['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x2a0196['slice'](0x0,0x8)+'-'+_0x2a0196['slice'](0x8,0xc)+'-'+_0x2a0196['slice'](0xc,0x10)+'-'+_0x2a0196['slice'](0x10,0x14)+'-'+_0x2a0196['slice'](0x14);}return'corr_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function bareUserId(_0x29e663,_0x347c87){if(!_0x347c87||'string'!=typeof _0x347c87)return'';const _0x13d7bf=_0x29e663+':';if(_0x347c87['startsWith'](_0x13d7bf))return _0x347c87['slice'](_0x13d7bf['length']);const _0x3cef8b=_0x347c87['indexOf'](':');return _0x3cef8b>=0x0?_0x347c87['slice'](_0x3cef8b+0x1):_0x347c87;}export async function invokeRemoteAgent(_0xe3ba63){const {notifier:_0x28b0f8,senderId:_0x38c5c5,receiverId:_0x1ad86b,agentName:_0x52848b,input:_0x326783,state:_0x454923,trace:_0x135279=null,timeoutMs:_0x1081ce=DEFAULT_TIMEOUT_MS}=_0xe3ba63;if(!(null==_0x28b0f8?void 0x0:_0x28b0f8['isConnected']))throw new WorkflowError('Remote\x20agent\x20invoke\x20requires\x20a\x20connected\x20notifier');if(!_0x1ad86b)throw new WorkflowError('Remote\x20agent\x20\x22'+_0x52848b+'\x22\x20is\x20missing\x20receiverId');const _0x371636=correlationId(),_0x4c593d=createInvokeEnvelope({'correlationId':_0x371636,'agentName':_0x52848b,'input':_0x326783,'state':null!=_0x454923?_0x454923:null,'trace':_0x135279,'replyTo':_0x38c5c5}),_0x573dd9=_0x28b0f8['_awaitRemoteAgentReply'](_0x371636,{'timeoutMs':_0x1081ce,'agentName':_0x52848b});return await _0x28b0f8['send']({'senderId':_0x38c5c5,'receiverId':_0x1ad86b,'data':_0x4c593d,'saveHistory':!0x1}),_0x573dd9;}export async function sendRemoteAgentResult(_0x58cfac,_0x56063f){var _0x540ef1;await _0x58cfac['send']({'senderId':_0x56063f['senderId'],'receiverId':_0x56063f['receiverId'],'data':createResultEnvelope({'correlationId':_0x56063f['correlationId'],'agentName':_0x56063f['agentName'],'output':_0x56063f['output'],'state':null!==(_0x540ef1=_0x56063f['state'])&&void 0x0!==_0x540ef1?_0x540ef1:null}),'saveHistory':!0x1});}export async function sendRemoteAgentError(_0x13b8de,_0x18e32b){await _0x13b8de['send']({'senderId':_0x18e32b['senderId'],'receiverId':_0x18e32b['receiverId'],'data':createErrorEnvelope({'correlationId':_0x18e32b['correlationId'],'agentName':_0x18e32b['agentName'],'message':_0x18e32b['message']}),'saveHistory':!0x1});}export function isRemoteAgentReply(_0x2961cf){return null!=_0x2961cf&&'object'==typeof _0x2961cf&&(_0x2961cf['op']===REMOTE_AGENT_OP['RESULT']||_0x2961cf['op']===REMOTE_AGENT_OP['ERROR']);}export{DEFAULT_TIMEOUT_MS};
1
+ import{WorkflowError}from'./errors.js';import{createErrorEnvelope,createInvokeEnvelope,createResultEnvelope,REMOTE_AGENT_OP}from'./remoteAgentProtocol.js';const DEFAULT_TIMEOUT_MS=0x1d4c0;function correlationId(){const _0x55befd='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x55befd&&'function'==typeof _0x55befd['randomUUID'])return _0x55befd['randomUUID']();if(_0x55befd&&_0x55befd['getRandomValues']){const _0x36702a=new Uint8Array(0x10);_0x55befd['getRandomValues'](_0x36702a),_0x36702a[0x6]=0xf&_0x36702a[0x6]|0x40,_0x36702a[0x8]=0x3f&_0x36702a[0x8]|0x80;const _0x2de852=[..._0x36702a]['map'](_0x1cdefc=>_0x1cdefc['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x2de852['slice'](0x0,0x8)+'-'+_0x2de852['slice'](0x8,0xc)+'-'+_0x2de852['slice'](0xc,0x10)+'-'+_0x2de852['slice'](0x10,0x14)+'-'+_0x2de852['slice'](0x14);}return'corr_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function bareUserId(_0x25af61,_0x471262){if(!_0x471262||'string'!=typeof _0x471262)return'';const _0x598c24=_0x25af61+':';if(_0x471262['startsWith'](_0x598c24))return _0x471262['slice'](_0x598c24['length']);const _0x4fe80a=_0x471262['indexOf'](':');return _0x4fe80a>=0x0?_0x471262['slice'](_0x4fe80a+0x1):_0x471262;}export async function invokeRemoteAgent(_0x285423){const {notifier:_0xe681ca,senderId:_0x51340d,receiverId:_0x44aedc,agentName:_0x4f9164,input:_0x230867,state:_0x3bc48b,trace:_0xdafb6f=null,timeoutMs:_0x3cf0bd=DEFAULT_TIMEOUT_MS}=_0x285423;if(!(null==_0xe681ca?void 0x0:_0xe681ca['isConnected']))throw new WorkflowError('Remote\x20agent\x20invoke\x20requires\x20a\x20connected\x20notifier');if(!_0x44aedc)throw new WorkflowError('Remote\x20agent\x20\x22'+_0x4f9164+'\x22\x20is\x20missing\x20receiverId');const _0x2debda=correlationId(),_0x4f3080=createInvokeEnvelope({'correlationId':_0x2debda,'agentName':_0x4f9164,'input':_0x230867,'state':null!=_0x3bc48b?_0x3bc48b:null,'trace':_0xdafb6f,'replyTo':_0x51340d}),_0x46c8e5=_0xe681ca['_awaitRemoteAgentReply'](_0x2debda,{'timeoutMs':_0x3cf0bd,'agentName':_0x4f9164});return await _0xe681ca['send']({'senderId':_0x51340d,'receiverId':_0x44aedc,'data':_0x4f3080,'saveHistory':!0x1}),_0x46c8e5;}export async function sendRemoteAgentResult(_0x41ded7,_0x426f76){var _0x3851c6;await _0x41ded7['send']({'senderId':_0x426f76['senderId'],'receiverId':_0x426f76['receiverId'],'data':createResultEnvelope({'correlationId':_0x426f76['correlationId'],'agentName':_0x426f76['agentName'],'output':_0x426f76['output'],'state':null!==(_0x3851c6=_0x426f76['state'])&&void 0x0!==_0x3851c6?_0x3851c6:null}),'saveHistory':!0x1});}export async function sendRemoteAgentError(_0x567900,_0x2bee6f){await _0x567900['send']({'senderId':_0x2bee6f['senderId'],'receiverId':_0x2bee6f['receiverId'],'data':createErrorEnvelope({'correlationId':_0x2bee6f['correlationId'],'agentName':_0x2bee6f['agentName'],'message':_0x2bee6f['message']}),'saveHistory':!0x1});}export function isRemoteAgentReply(_0x529d69){return null!=_0x529d69&&'object'==typeof _0x529d69&&(_0x529d69['op']===REMOTE_AGENT_OP['RESULT']||_0x529d69['op']===REMOTE_AGENT_OP['ERROR']);}export{DEFAULT_TIMEOUT_MS};
@@ -1 +1 @@
1
- export const REMOTE_AGENT_KIND='dnotifier.remoteAgent';export const REMOTE_AGENT_OP={'INVOKE':'invoke','RESULT':'result','ERROR':'error'};export function isRemoteAgentEnvelope(_0xbcc4e9){return null!=_0xbcc4e9&&'object'==typeof _0xbcc4e9&&_0xbcc4e9['__dnotifier']===REMOTE_AGENT_KIND&&'string'==typeof _0xbcc4e9['op'];}export function isRemoteAgentRef(_0x5a11fb){return null!=_0x5a11fb&&'object'==typeof _0x5a11fb&&'string'==typeof _0x5a11fb['receiverId']&&''!==_0x5a11fb['receiverId']['trim']()&&'function'!=typeof _0x5a11fb['run'];}export function createInvokeEnvelope(_0x309b9a){var _0x233bc4,_0x516a63,_0x5b0153;return{'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['INVOKE'],'correlationId':_0x309b9a['correlationId'],'agentName':_0x309b9a['agentName'],'input':null!==(_0x233bc4=_0x309b9a['input'])&&void 0x0!==_0x233bc4?_0x233bc4:null,'state':null!==(_0x516a63=_0x309b9a['state'])&&void 0x0!==_0x516a63?_0x516a63:null,'trace':null!==(_0x5b0153=_0x309b9a['trace'])&&void 0x0!==_0x5b0153?_0x5b0153:null,'replyTo':_0x309b9a['replyTo']};}export function createResultEnvelope(_0x1832da){var _0x1ee1eb,_0x33cab1;const _0xcb09cf={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['RESULT'],'correlationId':_0x1832da['correlationId']};return _0x1832da['agentName']&&(_0xcb09cf['agentName']=_0x1832da['agentName']),_0xcb09cf['output']=null!==(_0x1ee1eb=_0x1832da['output'])&&void 0x0!==_0x1ee1eb?_0x1ee1eb:null,_0xcb09cf['state']=null!==(_0x33cab1=_0x1832da['state'])&&void 0x0!==_0x33cab1?_0x33cab1:null,_0xcb09cf;}export function createErrorEnvelope(_0x19fef0){const _0x480a8c={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['ERROR'],'correlationId':_0x19fef0['correlationId']};return _0x19fef0['agentName']&&(_0x480a8c['agentName']=_0x19fef0['agentName']),_0x480a8c['error']={'message':_0x19fef0['message']},_0x480a8c;}
1
+ export const REMOTE_AGENT_KIND='dnotifier.remoteAgent';export const REMOTE_AGENT_OP={'INVOKE':'invoke','RESULT':'result','ERROR':'error'};export function isRemoteAgentEnvelope(_0x5a590d){return null!=_0x5a590d&&'object'==typeof _0x5a590d&&_0x5a590d['__dnotifier']===REMOTE_AGENT_KIND&&'string'==typeof _0x5a590d['op'];}export function isRemoteAgentRef(_0x3b9a12){return null!=_0x3b9a12&&'object'==typeof _0x3b9a12&&'string'==typeof _0x3b9a12['receiverId']&&''!==_0x3b9a12['receiverId']['trim']()&&'function'!=typeof _0x3b9a12['run'];}export function createInvokeEnvelope(_0x3fced9){var _0x333381,_0x1f8adf,_0x4c13be;return{'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['INVOKE'],'correlationId':_0x3fced9['correlationId'],'agentName':_0x3fced9['agentName'],'input':null!==(_0x333381=_0x3fced9['input'])&&void 0x0!==_0x333381?_0x333381:null,'state':null!==(_0x1f8adf=_0x3fced9['state'])&&void 0x0!==_0x1f8adf?_0x1f8adf:null,'trace':null!==(_0x4c13be=_0x3fced9['trace'])&&void 0x0!==_0x4c13be?_0x4c13be:null,'replyTo':_0x3fced9['replyTo']};}export function createResultEnvelope(_0x4dacc6){var _0x52b7ab,_0x821656;const _0x178545={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['RESULT'],'correlationId':_0x4dacc6['correlationId']};return _0x4dacc6['agentName']&&(_0x178545['agentName']=_0x4dacc6['agentName']),_0x178545['output']=null!==(_0x52b7ab=_0x4dacc6['output'])&&void 0x0!==_0x52b7ab?_0x52b7ab:null,_0x178545['state']=null!==(_0x821656=_0x4dacc6['state'])&&void 0x0!==_0x821656?_0x821656:null,_0x178545;}export function createErrorEnvelope(_0x4bb69f){const _0x40c4b8={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['ERROR'],'correlationId':_0x4bb69f['correlationId']};return _0x4bb69f['agentName']&&(_0x40c4b8['agentName']=_0x4bb69f['agentName']),_0x40c4b8['error']={'message':_0x4bb69f['message']},_0x40c4b8;}
@@ -10,7 +10,7 @@ export class WorkflowRunner {
10
10
  run(params: {
11
11
  input: any;
12
12
  }): Promise<{
13
- result: any;
13
+ result: unknown;
14
14
  state: {};
15
15
  }>;
16
16
  }
@@ -1 +1 @@
1
- import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';import{WorkflowError}from'./errors.js';import{STEP_TYPE_END,STEP_TYPE_ENTRY}from'./stepTypes.js';function snapshot(_0xeded5){try{return void 0x0===_0xeded5?null:JSON['parse'](JSON['stringify'](_0xeded5));}catch{return String(_0xeded5);}}export class WorkflowRunner{constructor({notifier:_0x35f264,senderId:_0x1a119f,workflow:_0x127fa5}){if(!_0x35f264)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20DNotifier\x20instance');if(!_0x1a119f)throw new WorkflowError('WorkflowRunner\x20requires\x20senderId');if(!_0x127fa5)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20workflow');this['notifier']=_0x35f264,this['senderId']=_0x1a119f,this['workflow']=_0x127fa5;}async['run'](_0x141d81){var _0x848894,_0x3ef59e,_0x11a01f;const _0xf1974=null==_0x141d81?void 0x0:_0x141d81['input'],_0x4e0816={};let _0x1860f4=null,_0x59a6d7=null,_0x1d55c1=null;const _0xcc526f=Date['now']();if(this['workflow']['observability']){_0x1860f4=createWorkflowObservability({'appId':this['notifier']['appId'],'token':null!==(_0x848894=this['notifier']['authToken'])&&void 0x0!==_0x848894?_0x848894:null}),await _0x1860f4['registerWorkflow'](this['workflow']);const _0x3f9795=await _0x1860f4['startExecution']({'workflowId':this['workflow']['name'],'userId':this['senderId'],'input':_0xf1974,'startedAtMs':_0xcc526f,'startedAt':new Date(_0xcc526f)['toISOString']()});_0x59a6d7=_0x3f9795['executionId'],_0x1d55c1=_0x3f9795['startedAt'];}let _0x332611=null;if(_0x1860f4&&_0x59a6d7){const _0xb0a912=await _0x1860f4['recordStep'](_0x59a6d7,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':this['workflow']['name'],'status':'ok','latencyMs':0x0,'parentStepId':null,'input':snapshot(_0xf1974),'state':snapshot(_0x4e0816)});_0x332611=null!==(_0x3ef59e=null==_0xb0a912?void 0x0:_0xb0a912['id'])&&void 0x0!==_0x3ef59e?_0x3ef59e:null;}const _0x50e275=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0xf1974,'state':_0x4e0816,'observability':_0x1860f4,'executionId':_0x59a6d7,'entryStepId':_0x332611});let _0x1b1eb9,_0x359a30='ok',_0x181bd1=null;try{_0x1b1eb9=await this['workflow']['entry'](_0x50e275);}catch(_0x5b4786){throw _0x359a30='error',_0x181bd1={'message':null!==(_0x11a01f=null==_0x5b4786?void 0x0:_0x5b4786['message'])&&void 0x0!==_0x11a01f?_0x11a01f:String(_0x5b4786),'stack':null==_0x5b4786?void 0x0:_0x5b4786['stack']},_0x5b4786;}finally{if(_0x1860f4&&_0x59a6d7){await _0x1860f4['recordStep'](_0x59a6d7,{'type':STEP_TYPE_END,'kind':'end','label':this['workflow']['name'],'status':_0x359a30,'latencyMs':0x0,'parentStepId':_0x50e275['getEndParentStepId'](),'output':snapshot('ok'===_0x359a30?_0x1b1eb9:null),'state':snapshot(_0x50e275['state']),'error':_0x181bd1});const _0x29406f=Date['now'](),_0x85aeb6=new Date(_0x29406f)['toISOString'](),_0x42298f=_0x1860f4['getStepCount']();await _0x1860f4['completeExecution']({'executionId':_0x59a6d7,'status':_0x359a30,'endedAt':_0x85aeb6,'durationMs':_0x29406f-_0xcc526f,'stepCount':_0x42298f,'error':_0x181bd1,'result':'ok'===_0x359a30?_0x1b1eb9:null,'startedAt':_0x1d55c1});}}const _0x4e7a45={'result':_0x1b1eb9,'state':_0x4e0816};return _0x59a6d7&&(_0x4e7a45['executionId']=_0x59a6d7),_0x4e7a45;}}
1
+ import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';import{WorkflowError}from'./errors.js';import{STEP_TYPE_END,STEP_TYPE_ENTRY}from'./stepTypes.js';import{withWorkflowMiddleware}from'../agent-runtime/middleware.js';function snapshot(_0x4d90d0){try{return void 0x0===_0x4d90d0?null:JSON['parse'](JSON['stringify'](_0x4d90d0));}catch{return String(_0x4d90d0);}}export class WorkflowRunner{constructor({notifier:_0x5ccafc,senderId:_0x29545,workflow:_0x19f7bf}){if(!_0x5ccafc)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20DNotifier\x20instance');if(!_0x29545)throw new WorkflowError('WorkflowRunner\x20requires\x20senderId');if(!_0x19f7bf)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20workflow');this['notifier']=_0x5ccafc,this['senderId']=_0x29545,this['workflow']=_0x19f7bf;}async['run'](_0x337c92){var _0x6e14f,_0x43fd55,_0x1ca089;const _0x4d31bc=null==_0x337c92?void 0x0:_0x337c92['input'],_0x354814={};let _0x3cc23c=null,_0x50e921=null,_0x45b08b=null;const _0x2461b7=Date['now']();if(this['workflow']['observability']){_0x3cc23c=createWorkflowObservability({'appId':this['notifier']['appId'],'token':null!==(_0x6e14f=this['notifier']['authToken'])&&void 0x0!==_0x6e14f?_0x6e14f:null}),await _0x3cc23c['registerWorkflow'](this['workflow']);const _0x3f8258=await _0x3cc23c['startExecution']({'workflowId':this['workflow']['name'],'userId':this['senderId'],'input':_0x4d31bc,'startedAtMs':_0x2461b7,'startedAt':new Date(_0x2461b7)['toISOString']()});_0x50e921=_0x3f8258['executionId'],_0x45b08b=_0x3f8258['startedAt'];}let _0x4f6f7e=null;if(_0x3cc23c&&_0x50e921){const _0x2db406=await _0x3cc23c['recordStep'](_0x50e921,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':this['workflow']['name'],'status':'ok','latencyMs':0x0,'parentStepId':null,'input':snapshot(_0x4d31bc),'state':snapshot(_0x354814)});_0x4f6f7e=null!==(_0x43fd55=null==_0x2db406?void 0x0:_0x2db406['id'])&&void 0x0!==_0x43fd55?_0x43fd55:null;}const _0x354619=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x4d31bc,'state':_0x354814,'observability':_0x3cc23c,'executionId':_0x50e921,'entryStepId':_0x4f6f7e});let _0x30ab71,_0x35cbd9='ok',_0x4dadd9=null;try{_0x30ab71=await withWorkflowMiddleware(this['workflow'],_0x354619,()=>this['workflow']['entry'](_0x354619));}catch(_0x8e79e){throw _0x35cbd9='error',_0x4dadd9={'message':null!==(_0x1ca089=null==_0x8e79e?void 0x0:_0x8e79e['message'])&&void 0x0!==_0x1ca089?_0x1ca089:String(_0x8e79e),'stack':null==_0x8e79e?void 0x0:_0x8e79e['stack']},_0x8e79e;}finally{if(_0x3cc23c&&_0x50e921){await _0x3cc23c['recordStep'](_0x50e921,{'type':STEP_TYPE_END,'kind':'end','label':this['workflow']['name'],'status':_0x35cbd9,'latencyMs':0x0,'parentStepId':_0x354619['getEndParentStepId'](),'output':snapshot('ok'===_0x35cbd9?_0x30ab71:null),'state':snapshot(_0x354619['state']),'error':_0x4dadd9});const _0x4df6ed=Date['now'](),_0x3c31f4=new Date(_0x4df6ed)['toISOString'](),_0x5787df=_0x3cc23c['getStepCount']();await _0x3cc23c['completeExecution']({'executionId':_0x50e921,'status':_0x35cbd9,'endedAt':_0x3c31f4,'durationMs':_0x4df6ed-_0x2461b7,'stepCount':_0x5787df,'error':_0x4dadd9,'result':'ok'===_0x35cbd9?_0x30ab71:null,'startedAt':_0x45b08b});}}const _0x45df2c={'result':_0x30ab71,'state':_0x354814};return _0x50e921&&(_0x45df2c['executionId']=_0x50e921),_0x45df2c;}}
@@ -1 +1 @@
1
- export const STEP_TYPE_AGENT='Agent';export const STEP_TYPE_PARALLEL='Parallel';export const STEP_TYPE_ENTRY='Entry';export const STEP_TYPE_END='End';export const STEP_TYPE_CUSTOM='Custom';export const STEP_TYPE_TOOL='Tool';export const STRUCTURAL_STEP_TYPES=['Agent','Parallel','Entry','End','Custom','Tool'];export const SDK_API_STEP_TYPES=['sendAI','fetchAIHistory','search','addDocument','updateDocument','deleteDocument','listDocuments','getDocument'];export const LOG_TYPE_BY_API={'sendAI':'AI-LLM','fetchAIHistory':'AI\x20History','search':'Vector\x20Search','semanticSearch':'Vector\x20Search','addDocument':'Document\x20Add','updateDocument':'Document\x20Update','deleteDocument':'Document\x20Delete','listDocuments':'Document\x20List','getDocument':'Document\x20Get','agent':'Agent','tool':'Tool'};const LEGACY_KIND_TO_API={'ai_call':'sendAI','vector_call':'search'};export function toLogStepType(_0x9f4a08){if(null==_0x9f4a08||''===String(_0x9f4a08)['trim']())return'Custom';const _0x5e871b=String(_0x9f4a08);if(LOG_TYPE_BY_API[_0x5e871b])return LOG_TYPE_BY_API[_0x5e871b];const _0x7a2b96=_0x5e871b['toLowerCase']();for(const [_0x5f5d0a,_0x544370]of Object['entries'](LOG_TYPE_BY_API))if(_0x5f5d0a['toLowerCase']()===_0x7a2b96)return _0x544370;return _0x5e871b;}export function resolveApiName(_0x19f73b){const _0x1c8edd=null==_0x19f73b?void 0x0:_0x19f73b['kind'];if(null==_0x1c8edd||''===String(_0x1c8edd)['trim']())return null;const _0x2ec68c=String(_0x1c8edd);return LEGACY_KIND_TO_API[_0x2ec68c]?LEGACY_KIND_TO_API[_0x2ec68c]:'agent'===_0x2ec68c||SDK_API_STEP_TYPES['includes'](_0x2ec68c)||'semanticSearch'===_0x2ec68c?_0x2ec68c:null;}export function resolveStepType(_0x3a3600){if(null!=(null==_0x3a3600?void 0x0:_0x3a3600['type'])&&''!==String(_0x3a3600['type'])['trim']()){const _0x1250db=String(_0x3a3600['type'])['trim']();return STRUCTURAL_STEP_TYPES['includes'](_0x1250db)||Object['values'](LOG_TYPE_BY_API)['includes'](_0x1250db)?_0x1250db:toLogStepType(_0x1250db);}const _0x270c41=resolveApiName(_0x3a3600);return _0x270c41?toLogStepType(_0x270c41):'Custom';}
1
+ export const STEP_TYPE_AGENT='Agent';export const STEP_TYPE_PARALLEL='Parallel';export const STEP_TYPE_ENTRY='Entry';export const STEP_TYPE_END='End';export const STEP_TYPE_CUSTOM='Custom';export const STEP_TYPE_TOOL='Tool';export const STRUCTURAL_STEP_TYPES=['Agent','Parallel','Entry','End','Custom','Tool'];export const SDK_API_STEP_TYPES=['sendAI','fetchAIHistory','search','addDocument','updateDocument','deleteDocument','listDocuments','getDocument'];export const LOG_TYPE_BY_API={'sendAI':'AI-LLM','fetchAIHistory':'AI\x20History','search':'Vector\x20Search','semanticSearch':'Vector\x20Search','addDocument':'Document\x20Add','updateDocument':'Document\x20Update','deleteDocument':'Document\x20Delete','listDocuments':'Document\x20List','getDocument':'Document\x20Get','agent':'Agent','tool':'Tool'};const LEGACY_KIND_TO_API={'ai_call':'sendAI','vector_call':'search'};export function toLogStepType(_0x353ef6){if(null==_0x353ef6||''===String(_0x353ef6)['trim']())return'Custom';const _0x594d3d=String(_0x353ef6);if(LOG_TYPE_BY_API[_0x594d3d])return LOG_TYPE_BY_API[_0x594d3d];const _0x137348=_0x594d3d['toLowerCase']();for(const [_0x30e504,_0xf4e58d]of Object['entries'](LOG_TYPE_BY_API))if(_0x30e504['toLowerCase']()===_0x137348)return _0xf4e58d;return _0x594d3d;}export function resolveApiName(_0x4476a9){const _0x1c8aad=null==_0x4476a9?void 0x0:_0x4476a9['kind'];if(null==_0x1c8aad||''===String(_0x1c8aad)['trim']())return null;const _0xc2e97c=String(_0x1c8aad);return LEGACY_KIND_TO_API[_0xc2e97c]?LEGACY_KIND_TO_API[_0xc2e97c]:'agent'===_0xc2e97c||SDK_API_STEP_TYPES['includes'](_0xc2e97c)||'semanticSearch'===_0xc2e97c?_0xc2e97c:null;}export function resolveStepType(_0x7288cd){if(null!=(null==_0x7288cd?void 0x0:_0x7288cd['type'])&&''!==String(_0x7288cd['type'])['trim']()){const _0x11dc03=String(_0x7288cd['type'])['trim']();return STRUCTURAL_STEP_TYPES['includes'](_0x11dc03)||Object['values'](LOG_TYPE_BY_API)['includes'](_0x11dc03)?_0x11dc03:toLogStepType(_0x11dc03);}const _0x231f5b=resolveApiName(_0x7288cd);return _0x231f5b?toLogStepType(_0x231f5b):'Custom';}
@@ -1,15 +1,17 @@
1
1
  export class Workflow {
2
- constructor({ name, description, observability, capabilities, entry }: {
2
+ constructor({ name, description, observability, capabilities, middleware, entry, }: {
3
3
  name: string;
4
4
  description?: string;
5
5
  observability?: boolean;
6
6
  capabilities?: Partial<import("./capabilities.js").Capabilities> | string[];
7
+ middleware?: import("../agent-runtime/middleware.js").WorkflowMiddleware[];
7
8
  entry: (ctx: import("./context.js").WorkflowContext) => Promise<any>;
8
9
  });
9
10
  name: string;
10
11
  description: string | undefined;
11
12
  observability: boolean;
12
13
  capabilities: import("./capabilities.js").Capabilities;
14
+ middleware: import("../agent-runtime/middleware.js").WorkflowMiddleware[];
13
15
  entry: (ctx: import("./context.js").WorkflowContext) => Promise<any>;
14
16
  _agents: Map<string, AgentRegistration>;
15
17
  _registeredWithObservability: boolean;
@@ -1 +1 @@
1
- import{Agent}from'./agent.js';import{normalizeCapabilities}from'./capabilities.js';import{agentBackendId}from'../agent-runtime/ids.js';import{WorkflowError}from'./errors.js';import{isRemoteAgentRef}from'./remoteAgentProtocol.js';import{bareUserId,sendRemoteAgentError,sendRemoteAgentResult}from'./remoteAgentClient.js';import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';function normalizeDescription(_0x224fd9){if(null==_0x224fd9||''===_0x224fd9)return;if('string'!=typeof _0x224fd9)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20a\x20string');const _0xad5464=_0x224fd9['trim']();if(_0xad5464['length']>0x64)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20at\x20most\x20100\x20characters');return _0xad5464['length']>0x0?_0xad5464:void 0x0;}export class Workflow{constructor({name:_0x175b36,description:_0x310d88,observability:_0x373c4a=!0x1,capabilities:_0x5e58f4,entry:_0x40ee6d}){if(!_0x175b36||'string'!=typeof _0x175b36)throw new WorkflowError('Workflow\x20name\x20is\x20required');if('function'!=typeof _0x40ee6d)throw new WorkflowError('Workflow\x20entry\x20must\x20be\x20a\x20function');this['name']=_0x175b36['trim'](),this['description']=normalizeDescription(_0x310d88),this['observability']=Boolean(_0x373c4a),this['capabilities']=normalizeCapabilities(_0x5e58f4),this['entry']=_0x40ee6d,this['_agents']=new Map(),this['_registeredWithObservability']=!0x1,this['_listenNotifier']=null,this['_backendRegistrations']=new WeakMap();}['_syncBackendRegistration'](_0x58650e){var _0x30db3e,_0x47701f,_0x5cdfe9;const _0x107107=null===(_0x30db3e=null==_0x58650e?void 0x0:_0x58650e['_agentServices'])||void 0x0===_0x30db3e?void 0x0:_0x30db3e['sync'];if(!_0x107107||'function'!=typeof _0x107107['enqueueWorkflow'])return;for(const _0x40c2c1 of this['_agents']['values']())_0x40c2c1 instanceof Agent&&_0x107107['enqueueAgent'](_0x40c2c1);const _0x3c0e7e={'workflowId':this['name'],'name':this['name'],'description':null!==(_0x47701f=this['description'])&&void 0x0!==_0x47701f?_0x47701f:'','agentIds':[...this['_agents']]['map'](([_0x12d493,_0x4b1823])=>agentBackendId(_0x4b1823 instanceof Agent?_0x4b1823['name']:_0x12d493)),'hostUserId':null!==(_0x5cdfe9=_0x58650e['userId'])&&void 0x0!==_0x5cdfe9?_0x5cdfe9:null,'capabilities':this['capabilities']},_0xf4b644=JSON['stringify'](_0x3c0e7e);this['_backendRegistrations']['get'](_0x58650e)!==_0xf4b644&&(this['_backendRegistrations']['set'](_0x58650e,_0xf4b644),_0x107107['enqueueWorkflow'](_0x3c0e7e));}['registerAgent'](_0x4b96f3,_0x1cf700){if(!_0x4b96f3||'string'!=typeof _0x4b96f3)throw new WorkflowError('Agent\x20registration\x20name\x20is\x20required');if(isRemoteAgentRef(_0x1cf700))this['_agents']['set'](_0x4b96f3,{'receiverId':_0x1cf700['receiverId']['trim']()});else{if(!_0x1cf700||'function'!=typeof _0x1cf700['run'])throw new WorkflowError('Invalid\x20agent\x20for\x20\x22'+_0x4b96f3+'\x22\x20(expected\x20Agent\x20or\x20{\x20receiverId\x20})');this['_agents']['set'](_0x4b96f3,_0x1cf700);}return this['_listenNotifier']&&this['_syncBackendRegistration'](this['_listenNotifier']),this;}['registerAgents'](_0xe6fefa){for(const [_0x55dc0d,_0x43bf24]of Object['entries'](_0xe6fefa))this['registerAgent'](_0x55dc0d,_0x43bf24);return this;}['getAgent'](_0x12ffca){const _0x57d857=this['_agents']['get'](_0x12ffca);if(_0x57d857&&!isRemoteAgentRef(_0x57d857))return _0x57d857;}['getAgentRegistration'](_0x42b3df){return this['_agents']['get'](_0x42b3df);}['hasLocalAgent'](_0x13f7db){return Boolean(this['getAgent'](_0x13f7db));}['listen'](_0x483bb0){if(!_0x483bb0)throw new WorkflowError('workflow.listen\x20requires\x20a\x20DNotifier\x20instance');return this['_listenNotifier']&&this['_listenNotifier']!==_0x483bb0&&this['_listenNotifier']['_unregisterWorkflowListener'](this),this['_listenNotifier']=_0x483bb0,_0x483bb0['_registerWorkflowListener'](this),this['_syncBackendRegistration'](_0x483bb0),this;}['stopListening'](){var _0x2cbec8;return null===(_0x2cbec8=this['_listenNotifier'])||void 0x0===_0x2cbec8||_0x2cbec8['_unregisterWorkflowListener'](this),this['_listenNotifier']=null,this;}async['_handleRemoteInvoke'](_0x3066d2,_0x39868a,_0x4b6878){var _0x30701c,_0x5b97ed,_0x3dd161,_0x2f8993,_0x117ade,_0x14e7df,_0x44636d,_0x1aaa68;const _0x169a4f=_0x4b6878['agentName'],_0x3f2d27=_0x4b6878['correlationId'],_0xcdb5f3='string'==typeof _0x4b6878['replyTo']&&_0x4b6878['replyTo']['trim']()||bareUserId(_0x3066d2['appId'],null===(_0x30701c=null==_0x39868a?void 0x0:_0x39868a['metadata'])||void 0x0===_0x30701c?void 0x0:_0x30701c['sender']);if(!_0x3f2d27||!_0xcdb5f3)return;if(!this['hasLocalAgent'](_0x169a4f))return void await sendRemoteAgentError(_0x3066d2,{'senderId':_0x3066d2['userId'],'receiverId':_0xcdb5f3,'correlationId':_0x3f2d27,'agentName':_0x169a4f,'message':'Agent\x20not\x20hosted:\x20'+_0x169a4f});const _0x387ed5=_0x4b6878['state']&&'object'==typeof _0x4b6878['state']&&!Array['isArray'](_0x4b6878['state'])?{..._0x4b6878['state']}:{};let _0x2b6c4c=null;const _0x30e0fa=null!==(_0x3dd161=null===(_0x5b97ed=_0x4b6878['trace'])||void 0x0===_0x5b97ed?void 0x0:_0x5b97ed['executionId'])&&void 0x0!==_0x3dd161?_0x3dd161:null;_0x30e0fa&&this['observability']&&(_0x2b6c4c=createWorkflowObservability({'appId':_0x3066d2['appId'],'token':null!==(_0x2f8993=_0x3066d2['authToken'])&&void 0x0!==_0x2f8993?_0x2f8993:null,'appendOnly':!0x0}),await _0x2b6c4c['registerWorkflow'](this));const _0x22afb7=new WorkflowContext({'notifier':_0x3066d2,'senderId':_0x3066d2['userId'],'workflow':this,'input':null!==(_0x117ade=_0x4b6878['input'])&&void 0x0!==_0x117ade?_0x117ade:null,'state':_0x387ed5,'observability':_0x2b6c4c,'executionId':_0x30e0fa,'traceParentStepId':null!==(_0x44636d=null===(_0x14e7df=_0x4b6878['trace'])||void 0x0===_0x14e7df?void 0x0:_0x14e7df['parentStepId'])&&void 0x0!==_0x44636d?_0x44636d:null});try{const _0x5239cf=await _0x22afb7['runAgent'](_0x169a4f,{'input':void 0x0!==_0x4b6878['input']?_0x4b6878['input']:_0x22afb7['input']});await sendRemoteAgentResult(_0x3066d2,{'senderId':_0x3066d2['userId'],'receiverId':_0xcdb5f3,'correlationId':_0x3f2d27,'agentName':_0x169a4f,'output':_0x5239cf,'state':_0x22afb7['state']});}catch(_0x4f81b3){await sendRemoteAgentError(_0x3066d2,{'senderId':_0x3066d2['userId'],'receiverId':_0xcdb5f3,'correlationId':_0x3f2d27,'agentName':_0x169a4f,'message':null!==(_0x1aaa68=null==_0x4f81b3?void 0x0:_0x4f81b3['message'])&&void 0x0!==_0x1aaa68?_0x1aaa68:String(_0x4f81b3)});}}}
1
+ import{Agent}from'./agent.js';import{normalizeCapabilities}from'./capabilities.js';import{agentBackendId}from'../agent-runtime/ids.js';import{normalizeMiddleware}from'../agent-runtime/middleware.js';import{WorkflowError}from'./errors.js';import{isRemoteAgentRef}from'./remoteAgentProtocol.js';import{bareUserId,sendRemoteAgentError,sendRemoteAgentResult}from'./remoteAgentClient.js';import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';function normalizeDescription(_0x58b8fa){if(null==_0x58b8fa||''===_0x58b8fa)return;if('string'!=typeof _0x58b8fa)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20a\x20string');const _0x1e3a82=_0x58b8fa['trim']();if(_0x1e3a82['length']>0x64)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20at\x20most\x20100\x20characters');return _0x1e3a82['length']>0x0?_0x1e3a82:void 0x0;}export class Workflow{constructor({name:_0x4458ef,description:_0x721933,observability:_0x58f322=!0x1,capabilities:_0x2b58af,middleware:_0x5688a6,entry:_0x5d7ade}){if(!_0x4458ef||'string'!=typeof _0x4458ef)throw new WorkflowError('Workflow\x20name\x20is\x20required');if('function'!=typeof _0x5d7ade)throw new WorkflowError('Workflow\x20entry\x20must\x20be\x20a\x20function');this['name']=_0x4458ef['trim'](),this['description']=normalizeDescription(_0x721933),this['observability']=Boolean(_0x58f322),this['capabilities']=normalizeCapabilities(_0x2b58af),this['middleware']=normalizeMiddleware(_0x5688a6,this['name'],'Workflow'),this['entry']=_0x5d7ade,this['_agents']=new Map(),this['_registeredWithObservability']=!0x1,this['_listenNotifier']=null,this['_backendRegistrations']=new WeakMap();}['_syncBackendRegistration'](_0x18031f){var _0x2cdec4,_0x51a1be,_0x3b8889;const _0x34fb08=null===(_0x2cdec4=null==_0x18031f?void 0x0:_0x18031f['_agentServices'])||void 0x0===_0x2cdec4?void 0x0:_0x2cdec4['sync'];if(!_0x34fb08||'function'!=typeof _0x34fb08['enqueueWorkflow'])return;for(const _0x4df5d2 of this['_agents']['values']())_0x4df5d2 instanceof Agent&&_0x34fb08['enqueueAgent'](_0x4df5d2);const _0x3d3a13={'workflowId':this['name'],'name':this['name'],'description':null!==(_0x51a1be=this['description'])&&void 0x0!==_0x51a1be?_0x51a1be:'','agentIds':[...this['_agents']]['map'](([_0x451a92,_0x2246d0])=>agentBackendId(_0x2246d0 instanceof Agent?_0x2246d0['name']:_0x451a92)),'hostUserId':null!==(_0x3b8889=_0x18031f['userId'])&&void 0x0!==_0x3b8889?_0x3b8889:null,'capabilities':this['capabilities']},_0x3a9734=JSON['stringify'](_0x3d3a13);this['_backendRegistrations']['get'](_0x18031f)!==_0x3a9734&&(this['_backendRegistrations']['set'](_0x18031f,_0x3a9734),_0x34fb08['enqueueWorkflow'](_0x3d3a13));}['registerAgent'](_0x4da30e,_0x13200a){if(!_0x4da30e||'string'!=typeof _0x4da30e)throw new WorkflowError('Agent\x20registration\x20name\x20is\x20required');if(isRemoteAgentRef(_0x13200a))this['_agents']['set'](_0x4da30e,{'receiverId':_0x13200a['receiverId']['trim']()});else{if(!_0x13200a||'function'!=typeof _0x13200a['run'])throw new WorkflowError('Invalid\x20agent\x20for\x20\x22'+_0x4da30e+'\x22\x20(expected\x20Agent\x20or\x20{\x20receiverId\x20})');this['_agents']['set'](_0x4da30e,_0x13200a);}return this['_listenNotifier']&&this['_syncBackendRegistration'](this['_listenNotifier']),this;}['registerAgents'](_0x434118){for(const [_0x2382f4,_0x20cdfb]of Object['entries'](_0x434118))this['registerAgent'](_0x2382f4,_0x20cdfb);return this;}['getAgent'](_0x4265a2){const _0x34e16e=this['_agents']['get'](_0x4265a2);if(_0x34e16e&&!isRemoteAgentRef(_0x34e16e))return _0x34e16e;}['getAgentRegistration'](_0x2e98b7){return this['_agents']['get'](_0x2e98b7);}['hasLocalAgent'](_0x322b1e){return Boolean(this['getAgent'](_0x322b1e));}['listen'](_0x4d70d5){if(!_0x4d70d5)throw new WorkflowError('workflow.listen\x20requires\x20a\x20DNotifier\x20instance');return this['_listenNotifier']&&this['_listenNotifier']!==_0x4d70d5&&this['_listenNotifier']['_unregisterWorkflowListener'](this),this['_listenNotifier']=_0x4d70d5,_0x4d70d5['_registerWorkflowListener'](this),this['_syncBackendRegistration'](_0x4d70d5),this;}['stopListening'](){var _0x3653fb;return null===(_0x3653fb=this['_listenNotifier'])||void 0x0===_0x3653fb||_0x3653fb['_unregisterWorkflowListener'](this),this['_listenNotifier']=null,this;}async['_handleRemoteInvoke'](_0x42cfc8,_0x5a860f,_0x2eaa9f){var _0x1bbbd4,_0x10d426,_0x5762ca,_0x40ccc6,_0x55d735,_0x142aa7,_0x47d1b8,_0x157846;const _0x3b9a90=_0x2eaa9f['agentName'],_0x1ea948=_0x2eaa9f['correlationId'],_0x57853e='string'==typeof _0x2eaa9f['replyTo']&&_0x2eaa9f['replyTo']['trim']()||bareUserId(_0x42cfc8['appId'],null===(_0x1bbbd4=null==_0x5a860f?void 0x0:_0x5a860f['metadata'])||void 0x0===_0x1bbbd4?void 0x0:_0x1bbbd4['sender']);if(!_0x1ea948||!_0x57853e)return;if(!this['hasLocalAgent'](_0x3b9a90))return void await sendRemoteAgentError(_0x42cfc8,{'senderId':_0x42cfc8['userId'],'receiverId':_0x57853e,'correlationId':_0x1ea948,'agentName':_0x3b9a90,'message':'Agent\x20not\x20hosted:\x20'+_0x3b9a90});const _0xb7c287=_0x2eaa9f['state']&&'object'==typeof _0x2eaa9f['state']&&!Array['isArray'](_0x2eaa9f['state'])?{..._0x2eaa9f['state']}:{};let _0x1dda06=null;const _0x4a7f5f=null!==(_0x5762ca=null===(_0x10d426=_0x2eaa9f['trace'])||void 0x0===_0x10d426?void 0x0:_0x10d426['executionId'])&&void 0x0!==_0x5762ca?_0x5762ca:null;_0x4a7f5f&&this['observability']&&(_0x1dda06=createWorkflowObservability({'appId':_0x42cfc8['appId'],'token':null!==(_0x40ccc6=_0x42cfc8['authToken'])&&void 0x0!==_0x40ccc6?_0x40ccc6:null,'appendOnly':!0x0}),await _0x1dda06['registerWorkflow'](this));const _0x363acd=new WorkflowContext({'notifier':_0x42cfc8,'senderId':_0x42cfc8['userId'],'workflow':this,'input':null!==(_0x55d735=_0x2eaa9f['input'])&&void 0x0!==_0x55d735?_0x55d735:null,'state':_0xb7c287,'observability':_0x1dda06,'executionId':_0x4a7f5f,'traceParentStepId':null!==(_0x47d1b8=null===(_0x142aa7=_0x2eaa9f['trace'])||void 0x0===_0x142aa7?void 0x0:_0x142aa7['parentStepId'])&&void 0x0!==_0x47d1b8?_0x47d1b8:null});try{const _0xa58393=await _0x363acd['runAgent'](_0x3b9a90,{'input':void 0x0!==_0x2eaa9f['input']?_0x2eaa9f['input']:_0x363acd['input']});await sendRemoteAgentResult(_0x42cfc8,{'senderId':_0x42cfc8['userId'],'receiverId':_0x57853e,'correlationId':_0x1ea948,'agentName':_0x3b9a90,'output':_0xa58393,'state':_0x363acd['state']});}catch(_0x786448){await sendRemoteAgentError(_0x42cfc8,{'senderId':_0x42cfc8['userId'],'receiverId':_0x57853e,'correlationId':_0x1ea948,'agentName':_0x3b9a90,'message':null!==(_0x157846=null==_0x786448?void 0x0:_0x786448['message'])&&void 0x0!==_0x157846?_0x157846:String(_0x786448)});}}}
@@ -1 +1 @@
1
- import{HttpTransport}from'../transport/httpTransport.js';import{DNotifierEndpoints}from'../config/endpoints.js';import{shortId}from'./ids.js';import{setJsonColumn}from'./jsonPayload.js';import{resolveStepType}from'./stepTypes.js';export class WorkflowObservabilityClient{constructor({appId:_0xb5d20f=null,token:_0xd9b1df=null,requestTimeoutMs:_0x3beda9=0x1388}={}){this['appId']=_0xb5d20f,this['token']=_0xd9b1df,this['requestTimeoutMs']=_0x3beda9;}['configure']({appId:_0x5dabb7,token:_0x4f8997,requestTimeoutMs:_0x2a4651}={}){void 0x0!==_0x5dabb7&&(this['appId']=_0x5dabb7),void 0x0!==_0x4f8997&&(this['token']=_0x4f8997),void 0x0!==_0x2a4651&&(this['requestTimeoutMs']=_0x2a4651);}['_transport'](_0xcf69a0){const _0x4a0d97=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0xcf69a0,'headers':_0x4a0d97,'timeoutMs':this['requestTimeoutMs']});}async['_post'](_0x90fbe0,_0x45cae0){if(this['token'])try{await this['_transport'](_0x90fbe0)['send'](_0x45cae0);}catch{}}async['registerWorkflow'](_0x34ab9d){const _0x22c66f={'appId':_0x34ab9d['appId'],'workflowId':_0x34ab9d['workflowId'],'name':_0x34ab9d['name']};return null!=_0x34ab9d['description']&&''!==_0x34ab9d['description']&&(_0x22c66f['description']=_0x34ab9d['description']),await this['_post'](DNotifierEndpoints['workflowRegisterUrl'],_0x22c66f),{'ok':!0x0};}async['createExecution'](_0x39dbb7){var _0x3cd5fe;const _0x2a3d72=null!==(_0x3cd5fe=_0x39dbb7['id'])&&void 0x0!==_0x3cd5fe?_0x3cd5fe:shortId('exec'),_0x11c622={'id':_0x2a3d72,'appId':_0x39dbb7['appId'],'workflowId':_0x39dbb7['workflowId'],'userId':_0x39dbb7['userId'],'status':'in_progress','stepCount':0x0,'startedAt':_0x39dbb7['startedAt']};return setJsonColumn(_0x11c622,'input',_0x39dbb7['input']),await this['_post'](DNotifierEndpoints['workflowExecutionsUrl'],_0x11c622),{'executionId':_0x2a3d72,'record':_0x11c622};}async['updateExecution'](_0x3c8859,_0x4ab95e){const _0x2068c3={'id':_0x3c8859,'status':_0x4ab95e['status'],'endedAt':_0x4ab95e['endedAt'],'durationMs':_0x4ab95e['durationMs'],'stepCount':_0x4ab95e['stepCount']};return setJsonColumn(_0x2068c3,'error',_0x4ab95e['error']),setJsonColumn(_0x2068c3,'result',_0x4ab95e['result']),await this['_post'](DNotifierEndpoints['workflowExecutionCompleteUrl'](_0x3c8859),_0x2068c3),{'ok':!0x0,'record':_0x2068c3};}async['addStep'](_0xb64d79,_0x5891f8){var _0x1f1da8,_0x487421,_0x3fc577,_0x16163e,_0x1cac01,_0x174c30;const _0x5b8a29=resolveStepType(_0x5891f8),_0x37ad71=null!==(_0x3fc577=null!==(_0x487421=null!==(_0x1f1da8=_0x5891f8['agentName'])&&void 0x0!==_0x1f1da8?_0x1f1da8:_0x5891f8['kind'])&&void 0x0!==_0x487421?_0x487421:_0x5891f8['apiName'])&&void 0x0!==_0x3fc577?_0x3fc577:null,_0x202f18={'id':_0x5891f8['id'],'executionId':_0xb64d79,'kind':_0x37ad71,'label':_0x5891f8['label'],'type':_0x5b8a29,'step_type':_0x5b8a29,'status':_0x5891f8['status'],'executedAt':_0x5891f8['executedAt'],'latencyMs':null!==(_0x16163e=_0x5891f8['latencyMs'])&&void 0x0!==_0x16163e?_0x16163e:0x0,'tokensIn':null!==(_0x1cac01=_0x5891f8['tokensIn'])&&void 0x0!==_0x1cac01?_0x1cac01:0x0,'tokensOut':null!==(_0x174c30=_0x5891f8['tokensOut'])&&void 0x0!==_0x174c30?_0x174c30:0x0};return null!=_0x5891f8['apiName']&&''!==_0x5891f8['apiName']&&(_0x202f18['apiName']=_0x5891f8['apiName']),null!=_0x5891f8['agentName']&&''!==_0x5891f8['agentName']&&(_0x202f18['agentName']=_0x5891f8['agentName']),null!=_0x5891f8['model']&&''!==_0x5891f8['model']&&(_0x202f18['model']='string'==typeof _0x5891f8['model']?_0x5891f8['model']:String(_0x5891f8['model'])),null!=_0x5891f8['provider']&&''!==_0x5891f8['provider']&&(_0x202f18['provider']='string'==typeof _0x5891f8['provider']?_0x5891f8['provider']:String(_0x5891f8['provider'])),setJsonColumn(_0x202f18,'input',_0x5891f8['input']),setJsonColumn(_0x202f18,'output',_0x5891f8['output']),setJsonColumn(_0x202f18,'state',_0x5891f8['state']),setJsonColumn(_0x202f18,'error',_0x5891f8['error']),null!=_0x5891f8['parentStepId']&&''!==_0x5891f8['parentStepId']&&(_0x202f18['parentStepId']=_0x5891f8['parentStepId']),null!=_0x5891f8['siblingIndex']&&''!==_0x5891f8['siblingIndex']&&(_0x202f18['siblingIndex']=_0x5891f8['siblingIndex']),null!=_0x5891f8['branchKey']&&''!==_0x5891f8['branchKey']&&(_0x202f18['branchKey']=_0x5891f8['branchKey']),await this['_post'](DNotifierEndpoints['workflowExecutionStepsUrl'](_0xb64d79),_0x202f18),{'ok':!0x0};}}
1
+ import{HttpTransport}from'../transport/httpTransport.js';import{DNotifierEndpoints}from'../config/endpoints.js';import{shortId}from'./ids.js';import{setJsonColumn}from'./jsonPayload.js';import{resolveStepType}from'./stepTypes.js';export class WorkflowObservabilityClient{constructor({appId:_0x2d2613=null,token:_0x268ac2=null,requestTimeoutMs:_0x29bab9=0x1388}={}){this['appId']=_0x2d2613,this['token']=_0x268ac2,this['requestTimeoutMs']=_0x29bab9;}['configure']({appId:_0x5b1790,token:_0x48a231,requestTimeoutMs:_0x46c15c}={}){void 0x0!==_0x5b1790&&(this['appId']=_0x5b1790),void 0x0!==_0x48a231&&(this['token']=_0x48a231),void 0x0!==_0x46c15c&&(this['requestTimeoutMs']=_0x46c15c);}['_transport'](_0x4aa03b){const _0x3b05fe=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x4aa03b,'headers':_0x3b05fe,'timeoutMs':this['requestTimeoutMs']});}async['_post'](_0x1d7f23,_0x2983ad){if(this['token'])try{await this['_transport'](_0x1d7f23)['send'](_0x2983ad);}catch{}}async['registerWorkflow'](_0x256438){const _0x1fde53={'appId':_0x256438['appId'],'workflowId':_0x256438['workflowId'],'name':_0x256438['name']};return null!=_0x256438['description']&&''!==_0x256438['description']&&(_0x1fde53['description']=_0x256438['description']),await this['_post'](DNotifierEndpoints['workflowRegisterUrl'],_0x1fde53),{'ok':!0x0};}async['createExecution'](_0x12b9e6){var _0x1c8a45;const _0x19bb67=null!==(_0x1c8a45=_0x12b9e6['id'])&&void 0x0!==_0x1c8a45?_0x1c8a45:shortId('exec'),_0x349a2a={'id':_0x19bb67,'appId':_0x12b9e6['appId'],'workflowId':_0x12b9e6['workflowId'],'userId':_0x12b9e6['userId'],'status':'in_progress','stepCount':0x0,'startedAt':_0x12b9e6['startedAt']};return setJsonColumn(_0x349a2a,'input',_0x12b9e6['input']),await this['_post'](DNotifierEndpoints['workflowExecutionsUrl'],_0x349a2a),{'executionId':_0x19bb67,'record':_0x349a2a};}async['updateExecution'](_0x4ccf8e,_0x3c8b8e){const _0x352901={'id':_0x4ccf8e,'status':_0x3c8b8e['status'],'endedAt':_0x3c8b8e['endedAt'],'durationMs':_0x3c8b8e['durationMs'],'stepCount':_0x3c8b8e['stepCount']};return setJsonColumn(_0x352901,'error',_0x3c8b8e['error']),setJsonColumn(_0x352901,'result',_0x3c8b8e['result']),await this['_post'](DNotifierEndpoints['workflowExecutionCompleteUrl'](_0x4ccf8e),_0x352901),{'ok':!0x0,'record':_0x352901};}async['addStep'](_0x33c3af,_0x2a392c){var _0x390eff,_0x91edf,_0x58c98d,_0xbb8fab,_0x4908b6,_0x3e89bb;const _0x1ab6ca=resolveStepType(_0x2a392c),_0x556685=null!==(_0x58c98d=null!==(_0x91edf=null!==(_0x390eff=_0x2a392c['agentName'])&&void 0x0!==_0x390eff?_0x390eff:_0x2a392c['kind'])&&void 0x0!==_0x91edf?_0x91edf:_0x2a392c['apiName'])&&void 0x0!==_0x58c98d?_0x58c98d:null,_0x83348b={'id':_0x2a392c['id'],'executionId':_0x33c3af,'kind':_0x556685,'label':_0x2a392c['label'],'type':_0x1ab6ca,'step_type':_0x1ab6ca,'status':_0x2a392c['status'],'executedAt':_0x2a392c['executedAt'],'latencyMs':null!==(_0xbb8fab=_0x2a392c['latencyMs'])&&void 0x0!==_0xbb8fab?_0xbb8fab:0x0,'tokensIn':null!==(_0x4908b6=_0x2a392c['tokensIn'])&&void 0x0!==_0x4908b6?_0x4908b6:0x0,'tokensOut':null!==(_0x3e89bb=_0x2a392c['tokensOut'])&&void 0x0!==_0x3e89bb?_0x3e89bb:0x0};return null!=_0x2a392c['apiName']&&''!==_0x2a392c['apiName']&&(_0x83348b['apiName']=_0x2a392c['apiName']),null!=_0x2a392c['agentName']&&''!==_0x2a392c['agentName']&&(_0x83348b['agentName']=_0x2a392c['agentName']),null!=_0x2a392c['model']&&''!==_0x2a392c['model']&&(_0x83348b['model']='string'==typeof _0x2a392c['model']?_0x2a392c['model']:String(_0x2a392c['model'])),null!=_0x2a392c['provider']&&''!==_0x2a392c['provider']&&(_0x83348b['provider']='string'==typeof _0x2a392c['provider']?_0x2a392c['provider']:String(_0x2a392c['provider'])),setJsonColumn(_0x83348b,'input',_0x2a392c['input']),setJsonColumn(_0x83348b,'output',_0x2a392c['output']),setJsonColumn(_0x83348b,'state',_0x2a392c['state']),setJsonColumn(_0x83348b,'error',_0x2a392c['error']),null!=_0x2a392c['parentStepId']&&''!==_0x2a392c['parentStepId']&&(_0x83348b['parentStepId']=_0x2a392c['parentStepId']),null!=_0x2a392c['siblingIndex']&&''!==_0x2a392c['siblingIndex']&&(_0x83348b['siblingIndex']=_0x2a392c['siblingIndex']),null!=_0x2a392c['branchKey']&&''!==_0x2a392c['branchKey']&&(_0x83348b['branchKey']=_0x2a392c['branchKey']),await this['_post'](DNotifierEndpoints['workflowExecutionStepsUrl'](_0x33c3af),_0x83348b),{'ok':!0x0};}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnotifier-realtime/dnotifier",
3
- "version": "1.1.30",
3
+ "version": "1.1.31",
4
4
  "description": "Official JavaScript SDK for DNotifier — AI agents, multi-agent workflows, RAG, and observability",
5
5
  "main": "dist/dnotifier.js",
6
6
  "types": "dist/dnotifier.d.ts",