@dnotifier-realtime/dnotifier 1.1.31 → 1.1.34

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 (59) 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.js +1 -1
  6. package/dist/agent-runtime/localCompletions.js +1 -1
  7. package/dist/agent-runtime/mcp/client.js +1 -1
  8. package/dist/agent-runtime/mcp/registry.js +1 -1
  9. package/dist/agent-runtime/middleware.js +1 -1
  10. package/dist/agent-runtime/observability.js +1 -1
  11. package/dist/agent-runtime/permissions.js +1 -1
  12. package/dist/agent-runtime/runtime.d.ts +11 -0
  13. package/dist/agent-runtime/runtime.js +1 -1
  14. package/dist/agent-runtime/schema.js +1 -1
  15. package/dist/agent-runtime/toolRegistry.js +1 -1
  16. package/dist/checkpoint/index.d.ts +128 -0
  17. package/dist/checkpoint/index.js +1 -0
  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.d.ts +4 -0
  27. package/dist/config/endpoints.js +1 -1
  28. package/dist/dnotifier.cjs +7 -7
  29. package/dist/dnotifier.d.ts +24 -3
  30. package/dist/dnotifier.js +1 -1
  31. package/dist/providers/openai.js +1 -1
  32. package/dist/transport/httpTransport.js +1 -1
  33. package/dist/transport/websocketTransport.js +1 -1
  34. package/dist/utils/buffer.js +1 -1
  35. package/dist/utils/frame.js +1 -1
  36. package/dist/utils/id.js +1 -1
  37. package/dist/utils/logs.js +1 -1
  38. package/dist/utils/payload.js +1 -1
  39. package/dist/workflow/agent.js +1 -1
  40. package/dist/workflow/capabilities.js +1 -1
  41. package/dist/workflow/context.d.ts +5 -1
  42. package/dist/workflow/context.js +1 -1
  43. package/dist/workflow/errors.js +1 -1
  44. package/dist/workflow/graphParents.js +1 -1
  45. package/dist/workflow/ids.js +1 -1
  46. package/dist/workflow/jsonPayload.js +1 -1
  47. package/dist/workflow/mockObservabilityClient.js +1 -1
  48. package/dist/workflow/observability.d.ts +3 -0
  49. package/dist/workflow/observability.js +1 -1
  50. package/dist/workflow/remoteAgentClient.d.ts +12 -0
  51. package/dist/workflow/remoteAgentClient.js +1 -1
  52. package/dist/workflow/remoteAgentProtocol.d.ts +8 -0
  53. package/dist/workflow/remoteAgentProtocol.js +1 -1
  54. package/dist/workflow/runner.d.ts +11 -1
  55. package/dist/workflow/runner.js +1 -1
  56. package/dist/workflow/stepTypes.js +1 -1
  57. package/dist/workflow/workflow.js +1 -1
  58. package/dist/workflow/workflowObservabilityClient.js +1 -1
  59. package/package.json +1 -1
@@ -1 +1 @@
1
- import{WorkflowError}from'./errors.js';import{formatParentStepId,resolveRecordedParentStepId}from'./graphParents.js';import{STEP_TYPE_AGENT,STEP_TYPE_CUSTOM,toLogStepType}from'./stepTypes.js';import{isRemoteAgentRef}from'./remoteAgentProtocol.js';import{invokeRemoteAgent}from'./remoteAgentClient.js';import{runAgentLoop,workflowTraceFromContext}from'../agent-runtime/runtime.js';function usageFromResponse(_0x3d6c98){var _0x2426ef,_0x387d44,_0x3f70b4,_0x301de3,_0x36b00f,_0x15ee90,_0x4fe960,_0x6ff87f,_0x3223f0,_0x57932f,_0x2ebeca,_0x210884,_0x38db9a;const _0x529a31=null!==(_0x3f70b4=null!==(_0x387d44=null===(_0x2426ef=null==_0x3d6c98?void 0x0:_0x3d6c98['data'])||void 0x0===_0x2426ef?void 0x0:_0x2426ef['usage'])&&void 0x0!==_0x387d44?_0x387d44:null==_0x3d6c98?void 0x0:_0x3d6c98['usage'])&&void 0x0!==_0x3f70b4?_0x3f70b4:null;return _0x529a31&&'object'==typeof _0x529a31?{'tokensIn':null!==(_0x15ee90=null!==(_0x36b00f=null!==(_0x301de3=_0x529a31['prompt_tokens'])&&void 0x0!==_0x301de3?_0x301de3:_0x529a31['input_tokens'])&&void 0x0!==_0x36b00f?_0x36b00f:_0x529a31['tokensIn'])&&void 0x0!==_0x15ee90?_0x15ee90:0x0,'tokensOut':null!==(_0x57932f=null!==(_0x3223f0=null!==(_0x6ff87f=null!==(_0x4fe960=_0x529a31['completion_tokens'])&&void 0x0!==_0x4fe960?_0x4fe960:_0x529a31['output_tokens'])&&void 0x0!==_0x6ff87f?_0x6ff87f:_0x529a31['total_tokens'])&&void 0x0!==_0x3223f0?_0x3223f0:_0x529a31['tokensOut'])&&void 0x0!==_0x57932f?_0x57932f:0x0,'model':null!==(_0x38db9a=null!==(_0x210884=null===(_0x2ebeca=null==_0x3d6c98?void 0x0:_0x3d6c98['data'])||void 0x0===_0x2ebeca?void 0x0:_0x2ebeca['model'])&&void 0x0!==_0x210884?_0x210884:_0x529a31['model'])&&void 0x0!==_0x38db9a?_0x38db9a:null}:{'tokensIn':0x0,'tokensOut':0x0,'model':null};}function firstNonEmpty(..._0x4cb0a5){for(const _0x406614 of _0x4cb0a5)if(null!=_0x406614&&''!==String(_0x406614)['trim']())return _0x406614;return null;}function snapshot(_0x46834c){try{return void 0x0===_0x46834c?null:JSON['parse'](JSON['stringify'](_0x46834c));}catch{return String(_0x46834c);}}function apiInput(_0x514f8d){if(!_0x514f8d||'object'!=typeof _0x514f8d)return null!=_0x514f8d?_0x514f8d:null;const {label:_0x57de85,dependsOn:_0x2f895b,parentStepIds:_0x174803,branchKey:_0x5bce09,siblingIndex:_0x52ce3b,parentStepId:_0xe25b24,input:_0x335e79,..._0x216017}=_0x514f8d;return Object['keys'](_0x216017)['length']>0x0?_0x216017:null;}function resolveAgentEdgeStepId({agentStepId:_0x292e27,output:_0x435e65,lastEdgeStepId:_0xba9617=null}){var _0x5257ff,_0x374897;const _0x29858f=_0x435e65&&'object'==typeof _0x435e65&&'string'==typeof _0x435e65['lastStepId']&&''!==_0x435e65['lastStepId']['trim']()?_0x435e65['lastStepId']:null,_0x425530=null!=_0xba9617&&''!==String(_0xba9617)['trim']()?String(_0xba9617):null;return null!==(_0x374897=null!==(_0x5257ff=null!=_0x29858f?_0x29858f:_0x425530)&&void 0x0!==_0x5257ff?_0x5257ff:_0x292e27)&&void 0x0!==_0x374897?_0x374897:null;}function normalizeRunAgentsSpec(_0x4fe9e0){if(Array['isArray'](_0x4fe9e0))return _0x4fe9e0['map']((_0x4a0cba,_0x3dddd6)=>{if('string'==typeof _0x4a0cba)return{'name':_0x4a0cba,'input':void 0x0,'key':String(_0x3dddd6)};if(!_0x4a0cba||'object'!=typeof _0x4a0cba||!_0x4a0cba['name'])throw new WorkflowError('runAgents\x20entry\x20requires\x20name');return{'name':_0x4a0cba['name'],'input':_0x4a0cba['input'],'key':String(_0x3dddd6)};});if(_0x4fe9e0&&'object'==typeof _0x4fe9e0)return Object['entries'](_0x4fe9e0)['map'](([_0x292370,_0x4a1d3c])=>_0x4a1d3c&&'object'==typeof _0x4a1d3c&&'name'in _0x4a1d3c?{'name':_0x4a1d3c['name'],'input':_0x4a1d3c['input'],'key':_0x292370}:{'name':_0x292370,'input':_0x4a1d3c,'key':_0x292370});throw new WorkflowError('runAgents\x20expects\x20an\x20array\x20or\x20object\x20spec');}export{formatParentStepId}from'./graphParents.js';export class WorkflowContext{constructor({notifier:_0x456caf,senderId:_0x8b3c2e,workflow:_0x5b0abf,input:_0x1e4bba,state:_0x189226={},observability:_0x1e9048=null,executionId:_0x5a0105=null,agentName:_0x575a1b=null,entryStepId:_0x17a064=null,traceParentStepId:_0x53ab1d=null,provider:_0x339789=null,model:_0x179f18=null}){this['notifier']=_0x456caf,this['senderId']=_0x8b3c2e,this['workflow']=_0x5b0abf,this['input']=_0x1e4bba,this['state']=_0x189226,this['_observability']=_0x1e9048,this['_executionId']=_0x5a0105,this['_observabilityEnabled']=Boolean(_0x5b0abf['observability']&&_0x1e9048&&_0x5a0105),this['agentName']=_0x575a1b,this['_entryStepId']=_0x17a064,this['_chainHeadStepId']=_0x17a064,this['_traceParentStepId']=_0x53ab1d,this['_currentStepId']=null,this['rootStepId']=null,this['_terminalStepIds']=[],this['_lastEdgeStepId']=null,this['_aiProvider']=null!=_0x339789&&''!==_0x339789?_0x339789:null,this['_aiModel']=null!=_0x179f18&&''!==_0x179f18?_0x179f18:null;}['getEndParentStepId'](){return this['_terminalStepIds']['length']>0x0?formatParentStepId(this['_terminalStepIds']):this['_entryStepId']?this['_entryStepId']:null;}['_markTerminalSteps'](_0x2d8d8a){this['_currentStepId']||(this['_terminalStepIds']=_0x2d8d8a['filter'](_0x32ed5e=>null!=_0x32ed5e&&''!==String(_0x32ed5e)['trim']()));}['_resolveParentStepId'](_0x42fae6={}){return void 0x0!==_0x42fae6['parentStepId']?_0x42fae6['parentStepId']:this['_currentStepId']?this['_currentStepId']:this['_traceParentStepId']?this['_traceParentStepId']:this['_chainHeadStepId']?this['_chainHeadStepId']:this['_entryStepId']?this['_entryStepId']:null;}['exportTraceContext'](){var _0x205270,_0x594480,_0x9803e3,_0x46005e;return{'executionId':this['_executionId'],'workflowId':this['workflow']['name'],'parentStepId':null!==(_0x46005e=null!==(_0x9803e3=null!==(_0x594480=null!==(_0x205270=this['_currentStepId'])&&void 0x0!==_0x205270?_0x205270:this['_chainHeadStepId'])&&void 0x0!==_0x594480?_0x594480:this['_traceParentStepId'])&&void 0x0!==_0x9803e3?_0x9803e3:this['_entryStepId'])&&void 0x0!==_0x46005e?_0x46005e:null};}async['_invokeSdkApi'](_0x49128c,_0x3626e9,_0x2b52d3={}){var _0x4026c0,_0x55f39c,_0x37b0b9,_0xf6efbe;const _0x2af293=Date['now']();let _0x319aa8='ok',_0x208cd9=null,_0x5e0ed5=null;const _0x4b65b7=toLogStepType(_0x49128c);try{return _0x208cd9=await _0x3626e9(),_0x208cd9;}catch(_0x6ba93f){throw _0x319aa8='error',_0x5e0ed5={'message':null!==(_0x4026c0=null==_0x6ba93f?void 0x0:_0x6ba93f['message'])&&void 0x0!==_0x4026c0?_0x4026c0:String(_0x6ba93f),'stack':null==_0x6ba93f?void 0x0:_0x6ba93f['stack']},_0x6ba93f;}finally{if(this['_observabilityEnabled']){const _0x3bc4b6=_0x2b52d3['usesTokens']?usageFromResponse(_0x208cd9):{'tokensIn':0x0,'tokensOut':0x0,'model':null},_0x566d28=firstNonEmpty(_0x2b52d3['model'],_0x3bc4b6['model'],null===(_0x55f39c=this['notifier'])||void 0x0===_0x55f39c?void 0x0:_0x55f39c['currentModel']),_0x5f3771=firstNonEmpty(_0x2b52d3['provider']),_0x4f417a=null!==(_0x37b0b9=this['agentName'])&&void 0x0!==_0x37b0b9?_0x37b0b9:_0x49128c;await this['_observability']['recordStep'](this['_executionId'],{'apiName':_0x49128c,'agentName':this['agentName'],'kind':_0x4f417a,'type':_0x4b65b7,'label':null!==(_0xf6efbe=_0x2b52d3['label'])&&void 0x0!==_0xf6efbe?_0xf6efbe:_0x4b65b7,'status':_0x319aa8,'latencyMs':Date['now']()-_0x2af293,'parentStepId':formatParentStepId(this['_currentStepId']),..._0x3bc4b6,'model':_0x566d28,'provider':_0x5f3771,'input':snapshot(_0x2b52d3['input']),'output':snapshot(_0x208cd9),'state':snapshot(this['state']),'error':_0x5e0ed5});}}}async['_runAgentObserved'](_0x2b99d3,_0x5317d7={}){var _0x571aa2,_0x422891,_0x3c86e1,_0x13a173,_0x5ac41f,_0x4548a4,_0xd39d75,_0x324caa,_0x4262f8,_0x30578e,_0x1f5c03;const _0x1dc431=this['workflow']['getAgentRegistration'](_0x2b99d3);if(!_0x1dc431)throw new WorkflowError('Agent\x20not\x20found:\x20'+_0x2b99d3);const _0x42e917=void 0x0!==_0x5317d7['input']?_0x5317d7['input']:this['input'],_0x47542b=resolveRecordedParentStepId({'parentStepId':_0x5317d7['parentStepId'],'parentStepIds':_0x5317d7['parentStepIds'],'dependsOn':_0x5317d7['dependsOn'],'resolveParent':()=>this['_resolveParentStepId'](_0x5317d7)}),_0x3cb4da=this['_observabilityEnabled']?this['_observability']['allocateStepId']():null,_0x42d406=Date['now']();let _0x270563='ok',_0x582196=null,_0x18fed3=null;try{if(isRemoteAgentRef(_0x1dc431)){const _0x40c163=this['_executionId']?{'executionId':this['_executionId'],'workflowId':this['workflow']['name'],'parentStepId':null!==(_0x13a173=null!==(_0x3c86e1=null!==(_0x422891=null!==(_0x571aa2=null!=_0x3cb4da?_0x3cb4da:this['_currentStepId'])&&void 0x0!==_0x571aa2?_0x571aa2:this['_chainHeadStepId'])&&void 0x0!==_0x422891?_0x422891:this['_traceParentStepId'])&&void 0x0!==_0x3c86e1?_0x3c86e1:this['_entryStepId'])&&void 0x0!==_0x13a173?_0x13a173:null}:null,_0x20eebb=await invokeRemoteAgent({'notifier':this['notifier'],'senderId':this['senderId'],'receiverId':_0x1dc431['receiverId'],'agentName':_0x2b99d3,'input':_0x42e917,'state':this['state'],'trace':_0x40c163,'timeoutMs':_0x5317d7['timeoutMs']});return _0x20eebb['state']&&'object'==typeof _0x20eebb['state']&&Object['assign'](this['state'],_0x20eebb['state']),_0x582196=_0x20eebb['output'],{'output':_0x582196,'stepId':_0x3cb4da,'edgeStepId':_0x3cb4da};}const _0x55e5de=_0x1dc431,_0x238ee3=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x42e917,'state':this['state'],'observability':this['_observability'],'executionId':this['_executionId'],'agentName':_0x2b99d3,'entryStepId':this['_entryStepId'],'traceParentStepId':this['_traceParentStepId'],'provider':null!==(_0x5ac41f=_0x55e5de['provider'])&&void 0x0!==_0x5ac41f?_0x5ac41f:null,'model':null!==(_0x4548a4=_0x55e5de['model'])&&void 0x0!==_0x4548a4?_0x4548a4:null});return _0x238ee3['_currentStepId']=_0x3cb4da,_0x582196=await _0x55e5de['run'](_0x238ee3),_0x3cb4da&&(_0x238ee3['rootStepId']=_0x3cb4da),{'output':_0x582196,'stepId':_0x3cb4da,'edgeStepId':resolveAgentEdgeStepId({'agentStepId':_0x3cb4da,'output':_0x582196,'lastEdgeStepId':_0x238ee3['_lastEdgeStepId']})};}catch(_0x22e74b){throw _0x270563='error',_0x18fed3={'message':null!==(_0xd39d75=null==_0x22e74b?void 0x0:_0x22e74b['message'])&&void 0x0!==_0xd39d75?_0xd39d75:String(_0x22e74b),'stack':null==_0x22e74b?void 0x0:_0x22e74b['stack']},_0x22e74b;}finally{if(this['_observabilityEnabled']&&_0x3cb4da){const _0x418f19=!isRemoteAgentRef(_0x1dc431)&&_0x1dc431?_0x1dc431:null;await this['_observability']['recordStep'](this['_executionId'],{'id':_0x3cb4da,'parentStepId':_0x47542b,'branchKey':null!==(_0x324caa=_0x5317d7['branchKey'])&&void 0x0!==_0x324caa?_0x324caa:null,'siblingIndex':null!==(_0x4262f8=_0x5317d7['siblingIndex'])&&void 0x0!==_0x4262f8?_0x4262f8:null,'agentName':_0x2b99d3,'kind':_0x2b99d3,'type':STEP_TYPE_AGENT,'label':_0x2b99d3,'status':_0x270563,'latencyMs':Date['now']()-_0x42d406,'model':null!==(_0x30578e=null==_0x418f19?void 0x0:_0x418f19['model'])&&void 0x0!==_0x30578e?_0x30578e:null,'provider':null!==(_0x1f5c03=null==_0x418f19?void 0x0:_0x418f19['provider'])&&void 0x0!==_0x1f5c03?_0x1f5c03:null,'input':snapshot(_0x42e917),'output':snapshot(_0x582196),'state':snapshot(this['state']),'error':_0x18fed3}),this['rootStepId']=_0x3cb4da,'ok'!==_0x270563||this['_currentStepId']||(this['_chainHeadStepId']=_0x3cb4da);}}}async['runAgent'](_0x118e2b,_0x10ac9e={}){const {output:_0x12fb9a,stepId:_0x102499,edgeStepId:_0x1173fb}=await this['_runAgentObserved'](_0x118e2b,_0x10ac9e);if(!this['_currentStepId']){const _0x4846ee=null!=_0x1173fb?_0x1173fb:_0x102499;_0x4846ee&&this['_markTerminalSteps']([_0x4846ee]);}return _0x12fb9a;}async['waitForMessage'](_0x253365={}){if(!this['notifier']||'function'!=typeof this['notifier']['_waitForInboundMessage'])throw new WorkflowError('waitForMessage\x20requires\x20a\x20DNotifier\x20instance');return this['notifier']['_waitForInboundMessage']({'timeoutMs':_0x253365['timeoutMs']});}async['runAgents'](_0x5cf275,_0x5954de={}){const _0x3049e7=normalizeRunAgentsSpec(_0x5cf275),_0x3f1c54=resolveRecordedParentStepId({'parentStepId':_0x5954de['parentStepId'],'resolveParent':()=>this['_resolveParentStepId'](_0x5954de)}),_0x4e3270=await Promise['all'](_0x3049e7['map']((_0x5db854,_0x25ab16)=>this['_runAgentObserved'](_0x5db854['name'],{'input':_0x5db854['input'],'parentStepId':_0x3f1c54,'siblingIndex':_0x25ab16}))),_0x5e4d61=_0x4e3270['map'](_0x48ec21=>_0x48ec21['output']),_0x55aaae=_0x4e3270['map'](_0x4aa8bc=>_0x4aa8bc['stepId']),_0x3039eb=_0x4e3270['map'](_0x14ce54=>{var _0x388ba9;return null!==(_0x388ba9=_0x14ce54['edgeStepId'])&&void 0x0!==_0x388ba9?_0x388ba9:_0x14ce54['stepId'];});if(this['_markTerminalSteps'](_0x3039eb),Array['isArray'](_0x5cf275))return{'results':_0x5e4d61,'stepIds':_0x55aaae};const _0x33eacf={};return _0x3049e7['forEach']((_0x2b278f,_0x44f8a4)=>{_0x33eacf[_0x2b278f['key']]=_0x5e4d61[_0x44f8a4];}),{'results':_0x33eacf,'stepIds':_0x55aaae};}async['sendAI'](_0x924951){var _0xf0744,_0x1016c2,_0x1a408f,_0x25d0a2,_0x185eeb,_0x30e931;const _0x3aa5d7=null!==(_0x1016c2=null!==(_0xf0744=null==_0x924951?void 0x0:_0x924951['provider'])&&void 0x0!==_0xf0744?_0xf0744:this['_aiProvider'])&&void 0x0!==_0x1016c2?_0x1016c2:void 0x0,_0x515987=null!==(_0x25d0a2=null!==(_0x1a408f=null==_0x924951?void 0x0:_0x924951['model'])&&void 0x0!==_0x1a408f?_0x1a408f:this['_aiModel'])&&void 0x0!==_0x25d0a2?_0x25d0a2:void 0x0,_0x4d2614=this['agentName']?this['workflow']['getAgent'](this['agentName']):void 0x0;return(null==_0x4d2614?void 0x0:_0x4d2614['hasTools'])?this['_invokeSdkApi']('sendAI',()=>{var _0x2e37df,_0x1fb211;return runAgentLoop({'notifier':this['notifier'],'agent':_0x4d2614,'input':null!==(_0x2e37df=null==_0x924951?void 0x0:_0x924951['message'])&&void 0x0!==_0x2e37df?_0x2e37df:this['input'],'executionId':this['_executionId'],'userId':this['senderId'],'sessionId':null!==(_0x1fb211=null==_0x924951?void 0x0:_0x924951['sessionId'])&&void 0x0!==_0x1fb211?_0x1fb211:null,'signal':null==_0x924951?void 0x0:_0x924951['signal'],'maxToolRounds':null==_0x924951?void 0x0:_0x924951['maxToolRounds'],'provider':_0x3aa5d7,'model':_0x515987,'metadata':null==_0x924951?void 0x0:_0x924951['metadata'],'middlewareCtx':this,'trace':workflowTraceFromContext(this)});},{'label':null==_0x924951?void 0x0:_0x924951['label'],'input':null!==(_0x185eeb=null==_0x924951?void 0x0:_0x924951['message'])&&void 0x0!==_0x185eeb?_0x185eeb:apiInput(_0x924951),'usesTokens':!0x0,'provider':_0x3aa5d7,'model':_0x515987}):this['_invokeSdkApi']('sendAI',()=>this['notifier']['sendAI']({'senderId':this['senderId'],..._0x924951,'provider':_0x3aa5d7,'model':_0x515987}),{'label':null==_0x924951?void 0x0:_0x924951['label'],'input':null!==(_0x30e931=null==_0x924951?void 0x0:_0x924951['message'])&&void 0x0!==_0x30e931?_0x30e931:apiInput(_0x924951),'usesTokens':!0x0,'provider':_0x3aa5d7,'model':_0x515987});}async['fetchAIHistory'](_0x4e9feb={}){return this['_invokeSdkApi']('fetchAIHistory',()=>this['notifier']['fetchAIHistory']({'senderId':this['senderId'],..._0x4e9feb}),{'label':null==_0x4e9feb?void 0x0:_0x4e9feb['label'],'input':apiInput(_0x4e9feb)});}async['search'](_0x1e8c60){return this['_invokeSdkApi']('search',()=>this['notifier']['search']({'senderId':this['senderId'],..._0x1e8c60}),{'label':null==_0x1e8c60?void 0x0:_0x1e8c60['label'],'input':apiInput(_0x1e8c60)});}async['addDocument'](_0x325567){return this['_invokeSdkApi']('addDocument',()=>this['notifier']['addDocument']({'senderId':this['senderId'],..._0x325567}),{'label':null==_0x325567?void 0x0:_0x325567['label'],'input':apiInput(_0x325567)});}async['updateDocument'](_0x48a153){return this['_invokeSdkApi']('updateDocument',()=>this['notifier']['updateDocument']({'senderId':this['senderId'],..._0x48a153}),{'label':null==_0x48a153?void 0x0:_0x48a153['label'],'input':apiInput(_0x48a153)});}async['deleteDocument'](_0x1e2876){return this['_invokeSdkApi']('deleteDocument',()=>this['notifier']['deleteDocument']({'senderId':this['senderId'],..._0x1e2876}),{'label':null==_0x1e2876?void 0x0:_0x1e2876['label'],'input':apiInput(_0x1e2876)});}async['listDocuments'](_0x24cdb9={}){return this['_invokeSdkApi']('listDocuments',()=>this['notifier']['listDocuments']({'senderId':this['senderId'],..._0x24cdb9}),{'label':null==_0x24cdb9?void 0x0:_0x24cdb9['label'],'input':apiInput(_0x24cdb9)});}async['getDocument'](_0x431e5b){return this['_invokeSdkApi']('getDocument',()=>this['notifier']['getDocument']({'senderId':this['senderId'],..._0x431e5b}),{'label':null==_0x431e5b?void 0x0:_0x431e5b['label'],'input':apiInput(_0x431e5b)});}async['recordStep'](_0x4eb0b6){var _0x2dfea2,_0x4a5841,_0x18f120,_0x57dda5,_0x3d6d40,_0x1edc4a,_0x434403,_0x42f79f,_0x7d2cfc,_0x19d3d3,_0x371d49,_0x32a259;if(!this['_observabilityEnabled'])return;const _0x4b9e50=null!=_0x4eb0b6['type']?toLogStepType(_0x4eb0b6['type']):STEP_TYPE_CUSTOM;await this['_observability']['recordStep'](this['_executionId'],{..._0x4eb0b6,'apiName':null!==(_0x2dfea2=_0x4eb0b6['apiName'])&&void 0x0!==_0x2dfea2?_0x2dfea2:_0x4eb0b6['kind'],'agentName':null!==(_0x4a5841=_0x4eb0b6['agentName'])&&void 0x0!==_0x4a5841?_0x4a5841:this['agentName'],'kind':null!==(_0x3d6d40=null!==(_0x57dda5=null!==(_0x18f120=_0x4eb0b6['agentName'])&&void 0x0!==_0x18f120?_0x18f120:this['agentName'])&&void 0x0!==_0x57dda5?_0x57dda5:_0x4eb0b6['kind'])&&void 0x0!==_0x3d6d40?_0x3d6d40:'custom','type':_0x4b9e50,'label':null!==(_0x1edc4a=_0x4eb0b6['label'])&&void 0x0!==_0x1edc4a?_0x1edc4a:_0x4b9e50,'tokensIn':null!==(_0x434403=_0x4eb0b6['tokensIn'])&&void 0x0!==_0x434403?_0x434403:0x0,'tokensOut':null!==(_0x42f79f=_0x4eb0b6['tokensOut'])&&void 0x0!==_0x42f79f?_0x42f79f:0x0,'model':null!==(_0x7d2cfc=_0x4eb0b6['model'])&&void 0x0!==_0x7d2cfc?_0x7d2cfc:null,'latencyMs':null!==(_0x19d3d3=_0x4eb0b6['latencyMs'])&&void 0x0!==_0x19d3d3?_0x19d3d3:0x0,'status':null!==(_0x371d49=_0x4eb0b6['status'])&&void 0x0!==_0x371d49?_0x371d49:'ok','error':null!==(_0x32a259=_0x4eb0b6['error'])&&void 0x0!==_0x32a259?_0x32a259:null,'parentStepId':null!=_0x4eb0b6['parentStepId']?formatParentStepId(_0x4eb0b6['parentStepId']):formatParentStepId(this['_currentStepId']),'input':snapshot(_0x4eb0b6['input']),'output':snapshot(_0x4eb0b6['output']),'state':snapshot(void 0x0!==_0x4eb0b6['state']?_0x4eb0b6['state']:this['state'])});}}
1
+ import{WorkflowError}from'./errors.js';import{formatParentStepId,resolveRecordedParentStepId}from'./graphParents.js';import{STEP_TYPE_AGENT,STEP_TYPE_CUSTOM,toLogStepType}from'./stepTypes.js';import{isRemoteAgentRef}from'./remoteAgentProtocol.js';import{invokeRemoteAgent}from'./remoteAgentClient.js';import{runAgentLoop,workflowTraceFromContext}from'../agent-runtime/runtime.js';function usageFromResponse(_0x221fe2){var _0x206634,_0x506d3b,_0x161c36,_0x175bfd,_0x52458a,_0x31d6c1,_0x78b6dd,_0x5323cf,_0x24d94d,_0x568cc8,_0x13b738,_0x18b8cc,_0x3c5392;const _0x7d49ef=null!==(_0x161c36=null!==(_0x506d3b=null===(_0x206634=null==_0x221fe2?void 0x0:_0x221fe2['data'])||void 0x0===_0x206634?void 0x0:_0x206634['usage'])&&void 0x0!==_0x506d3b?_0x506d3b:null==_0x221fe2?void 0x0:_0x221fe2['usage'])&&void 0x0!==_0x161c36?_0x161c36:null;return _0x7d49ef&&'object'==typeof _0x7d49ef?{'tokensIn':null!==(_0x31d6c1=null!==(_0x52458a=null!==(_0x175bfd=_0x7d49ef['prompt_tokens'])&&void 0x0!==_0x175bfd?_0x175bfd:_0x7d49ef['input_tokens'])&&void 0x0!==_0x52458a?_0x52458a:_0x7d49ef['tokensIn'])&&void 0x0!==_0x31d6c1?_0x31d6c1:0x0,'tokensOut':null!==(_0x568cc8=null!==(_0x24d94d=null!==(_0x5323cf=null!==(_0x78b6dd=_0x7d49ef['completion_tokens'])&&void 0x0!==_0x78b6dd?_0x78b6dd:_0x7d49ef['output_tokens'])&&void 0x0!==_0x5323cf?_0x5323cf:_0x7d49ef['total_tokens'])&&void 0x0!==_0x24d94d?_0x24d94d:_0x7d49ef['tokensOut'])&&void 0x0!==_0x568cc8?_0x568cc8:0x0,'model':null!==(_0x3c5392=null!==(_0x18b8cc=null===(_0x13b738=null==_0x221fe2?void 0x0:_0x221fe2['data'])||void 0x0===_0x13b738?void 0x0:_0x13b738['model'])&&void 0x0!==_0x18b8cc?_0x18b8cc:_0x7d49ef['model'])&&void 0x0!==_0x3c5392?_0x3c5392:null}:{'tokensIn':0x0,'tokensOut':0x0,'model':null};}function firstNonEmpty(..._0x343525){for(const _0x17376e of _0x343525)if(null!=_0x17376e&&''!==String(_0x17376e)['trim']())return _0x17376e;return null;}function snapshot(_0x9c4a2f){try{return void 0x0===_0x9c4a2f?null:JSON['parse'](JSON['stringify'](_0x9c4a2f));}catch{return String(_0x9c4a2f);}}function apiInput(_0x359e77){if(!_0x359e77||'object'!=typeof _0x359e77)return null!=_0x359e77?_0x359e77:null;const {label:_0x303558,dependsOn:_0x5d1d4f,parentStepIds:_0x1d9820,branchKey:_0x3ab1f5,siblingIndex:_0x3593f2,parentStepId:_0x5ccc4b,input:_0x539153,..._0x107992}=_0x359e77;return Object['keys'](_0x107992)['length']>0x0?_0x107992:null;}function resolveAgentEdgeStepId({agentStepId:_0x33d511,output:_0xe7ed68,lastEdgeStepId:_0x210f49=null}){var _0x351c82,_0x1d90d8;const _0x2c503a=_0xe7ed68&&'object'==typeof _0xe7ed68&&'string'==typeof _0xe7ed68['lastStepId']&&''!==_0xe7ed68['lastStepId']['trim']()?_0xe7ed68['lastStepId']:null,_0x12baaa=null!=_0x210f49&&''!==String(_0x210f49)['trim']()?String(_0x210f49):null;return null!==(_0x1d90d8=null!==(_0x351c82=null!=_0x2c503a?_0x2c503a:_0x12baaa)&&void 0x0!==_0x351c82?_0x351c82:_0x33d511)&&void 0x0!==_0x1d90d8?_0x1d90d8:null;}function normalizeRunAgentsSpec(_0x40ad37){if(Array['isArray'](_0x40ad37))return _0x40ad37['map']((_0x145444,_0x3b5ca3)=>{if('string'==typeof _0x145444)return{'name':_0x145444,'input':void 0x0,'key':String(_0x3b5ca3)};if(!_0x145444||'object'!=typeof _0x145444||!_0x145444['name'])throw new WorkflowError('runAgents\x20entry\x20requires\x20name');return{'name':_0x145444['name'],'input':_0x145444['input'],'key':String(_0x3b5ca3)};});if(_0x40ad37&&'object'==typeof _0x40ad37)return Object['entries'](_0x40ad37)['map'](([_0x3e8a08,_0x51f4d6])=>_0x51f4d6&&'object'==typeof _0x51f4d6&&'name'in _0x51f4d6?{'name':_0x51f4d6['name'],'input':_0x51f4d6['input'],'key':_0x3e8a08}:{'name':_0x3e8a08,'input':_0x51f4d6,'key':_0x3e8a08});throw new WorkflowError('runAgents\x20expects\x20an\x20array\x20or\x20object\x20spec');}export{formatParentStepId}from'./graphParents.js';export class WorkflowContext{constructor({notifier:_0x1201d0,senderId:_0x32619b,workflow:_0x2d5f3a,input:_0x1989c2,state:_0x2a8dbc={},observability:_0x2aa5ca=null,executionId:_0xa2d757=null,agentName:_0x34c3bd=null,entryStepId:_0x1273fa=null,traceParentStepId:_0x77687c=null,provider:_0x3a55da=null,model:_0x4933bd=null,sessionId:_0x5b46f3=null,checkpointer:_0x3ed955=null}){this['notifier']=_0x1201d0,this['senderId']=_0x32619b,this['workflow']=_0x2d5f3a,this['input']=_0x1989c2,this['state']=_0x2a8dbc,this['_observability']=_0x2aa5ca,this['_executionId']=_0xa2d757,this['_sessionId']=null!=_0x5b46f3?_0x5b46f3:null,this['_checkpointer']=null!=_0x3ed955?_0x3ed955:null,this['_observabilityEnabled']=Boolean(_0x2aa5ca&&_0xa2d757),this['agentName']=_0x34c3bd,this['_entryStepId']=_0x1273fa,this['_chainHeadStepId']=_0x1273fa,this['_traceParentStepId']=_0x77687c,this['_currentStepId']=null,this['rootStepId']=null,this['_terminalStepIds']=[],this['_lastEdgeStepId']=null,this['_aiProvider']=null!=_0x3a55da&&''!==_0x3a55da?_0x3a55da:null,this['_aiModel']=null!=_0x4933bd&&''!==_0x4933bd?_0x4933bd:null;}['getEndParentStepId'](){return this['_terminalStepIds']['length']>0x0?formatParentStepId(this['_terminalStepIds']):this['_entryStepId']?this['_entryStepId']:null;}['_markTerminalSteps'](_0x4d2ee1){this['_currentStepId']||(this['_terminalStepIds']=_0x4d2ee1['filter'](_0x40da23=>null!=_0x40da23&&''!==String(_0x40da23)['trim']()));}['_resolveParentStepId'](_0x110969={}){return void 0x0!==_0x110969['parentStepId']?_0x110969['parentStepId']:this['_currentStepId']?this['_currentStepId']:this['_traceParentStepId']?this['_traceParentStepId']:this['_chainHeadStepId']?this['_chainHeadStepId']:this['_entryStepId']?this['_entryStepId']:null;}['exportTraceContext'](){var _0x1d4841,_0xab216c,_0x4b3f13,_0x16011c;return{'executionId':this['_executionId'],'workflowId':this['workflow']['name'],'parentStepId':null!==(_0x16011c=null!==(_0x4b3f13=null!==(_0xab216c=null!==(_0x1d4841=this['_currentStepId'])&&void 0x0!==_0x1d4841?_0x1d4841:this['_chainHeadStepId'])&&void 0x0!==_0xab216c?_0xab216c:this['_traceParentStepId'])&&void 0x0!==_0x4b3f13?_0x4b3f13:this['_entryStepId'])&&void 0x0!==_0x16011c?_0x16011c:null};}async['_invokeSdkApi'](_0x25055b,_0x4a7c39,_0x412be8={}){var _0x1d163a,_0x5d1cd4,_0x350a45,_0x519f44;const _0xe4972c=Date['now']();let _0x5f584e='ok',_0x3649b9=null,_0x331a95=null;const _0x3ad311=toLogStepType(_0x25055b);try{return _0x3649b9=await _0x4a7c39(),_0x3649b9;}catch(_0x51a46d){throw _0x5f584e='error',_0x331a95={'message':null!==(_0x1d163a=null==_0x51a46d?void 0x0:_0x51a46d['message'])&&void 0x0!==_0x1d163a?_0x1d163a:String(_0x51a46d),'stack':null==_0x51a46d?void 0x0:_0x51a46d['stack']},_0x51a46d;}finally{if(this['_observabilityEnabled']){const _0x3eced4=_0x412be8['usesTokens']?usageFromResponse(_0x3649b9):{'tokensIn':0x0,'tokensOut':0x0,'model':null},_0x1336c6=firstNonEmpty(_0x412be8['model'],_0x3eced4['model'],null===(_0x5d1cd4=this['notifier'])||void 0x0===_0x5d1cd4?void 0x0:_0x5d1cd4['currentModel']),_0x544518=firstNonEmpty(_0x412be8['provider']),_0x470a50=null!==(_0x350a45=this['agentName'])&&void 0x0!==_0x350a45?_0x350a45:_0x25055b;await this['_observability']['recordStep'](this['_executionId'],{'apiName':_0x25055b,'agentName':this['agentName'],'kind':_0x470a50,'type':_0x3ad311,'label':null!==(_0x519f44=_0x412be8['label'])&&void 0x0!==_0x519f44?_0x519f44:_0x3ad311,'status':_0x5f584e,'latencyMs':Date['now']()-_0xe4972c,'parentStepId':formatParentStepId(this['_currentStepId']),..._0x3eced4,'model':_0x1336c6,'provider':_0x544518,'input':snapshot(_0x412be8['input']),'output':snapshot(_0x3649b9),'state':snapshot(this['state']),'error':_0x331a95});}}}async['_runAgentObserved'](_0x404cd3,_0x315dd9={}){var _0x48c162,_0x5f2a91,_0x5de922,_0x3a06a1,_0x46bc21,_0x4bdc5a,_0x28a40f,_0x3bdace,_0x4b630d,_0x35b8f4,_0x369354;const _0x55da63=this['workflow']['getAgentRegistration'](_0x404cd3);if(!_0x55da63)throw new WorkflowError('Agent\x20not\x20found:\x20'+_0x404cd3);const _0x3fe68c=void 0x0!==_0x315dd9['input']?_0x315dd9['input']:this['input'],_0x1ea163=resolveRecordedParentStepId({'parentStepId':_0x315dd9['parentStepId'],'parentStepIds':_0x315dd9['parentStepIds'],'dependsOn':_0x315dd9['dependsOn'],'resolveParent':()=>this['_resolveParentStepId'](_0x315dd9)}),_0x6b59c0=this['_observabilityEnabled']?this['_observability']['allocateStepId']():null,_0x57626c=Date['now']();let _0x4a70c9='ok',_0x45234c=null,_0x4dd2c0=null;try{if(isRemoteAgentRef(_0x55da63)){const _0x1827b7=this['_executionId']?{'executionId':this['_executionId'],'workflowId':this['workflow']['name'],'parentStepId':null!==(_0x3a06a1=null!==(_0x5de922=null!==(_0x5f2a91=null!==(_0x48c162=null!=_0x6b59c0?_0x6b59c0:this['_currentStepId'])&&void 0x0!==_0x48c162?_0x48c162:this['_chainHeadStepId'])&&void 0x0!==_0x5f2a91?_0x5f2a91:this['_traceParentStepId'])&&void 0x0!==_0x5de922?_0x5de922:this['_entryStepId'])&&void 0x0!==_0x3a06a1?_0x3a06a1:null}:null,_0x56baf8=await invokeRemoteAgent({'notifier':this['notifier'],'senderId':this['senderId'],'receiverId':_0x55da63['receiverId'],'agentName':_0x404cd3,'input':_0x3fe68c,'state':this['state'],'trace':_0x1827b7,'sessionId':this['_sessionId'],'fromCheckpointId':this['_fromCheckpointId'],'mode':this['_runMode'],'resume':this['_resume'],'timeoutMs':_0x315dd9['timeoutMs']});return _0x56baf8['state']&&'object'==typeof _0x56baf8['state']&&Object['assign'](this['state'],_0x56baf8['state']),_0x45234c=_0x56baf8['output'],{'output':_0x45234c,'stepId':_0x6b59c0,'edgeStepId':_0x6b59c0};}const _0x33592a=_0x55da63,_0x5495c1=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x3fe68c,'state':this['state'],'observability':this['_observability'],'executionId':this['_executionId'],'agentName':_0x404cd3,'entryStepId':this['_entryStepId'],'traceParentStepId':this['_traceParentStepId'],'provider':null!==(_0x46bc21=_0x33592a['provider'])&&void 0x0!==_0x46bc21?_0x46bc21:null,'model':null!==(_0x4bdc5a=_0x33592a['model'])&&void 0x0!==_0x4bdc5a?_0x4bdc5a:null,'sessionId':this['_sessionId'],'checkpointer':this['_checkpointer']});return _0x5495c1['_runMode']=this['_runMode'],_0x5495c1['_resume']=this['_resume'],_0x5495c1['_fromCheckpointId']=this['_fromCheckpointId'],_0x5495c1['_parentExecutionId']=this['_parentExecutionId'],_0x5495c1['_currentStepId']=_0x6b59c0,_0x45234c=await _0x33592a['run'](_0x5495c1),_0x6b59c0&&(_0x5495c1['rootStepId']=_0x6b59c0),{'output':_0x45234c,'stepId':_0x6b59c0,'edgeStepId':resolveAgentEdgeStepId({'agentStepId':_0x6b59c0,'output':_0x45234c,'lastEdgeStepId':_0x5495c1['_lastEdgeStepId']})};}catch(_0x348e5d){throw _0x4a70c9='error',_0x4dd2c0={'message':null!==(_0x28a40f=null==_0x348e5d?void 0x0:_0x348e5d['message'])&&void 0x0!==_0x28a40f?_0x28a40f:String(_0x348e5d),'stack':null==_0x348e5d?void 0x0:_0x348e5d['stack']},_0x348e5d;}finally{if(this['_observabilityEnabled']&&_0x6b59c0){const _0x40ad09=!isRemoteAgentRef(_0x55da63)&&_0x55da63?_0x55da63:null;await this['_observability']['recordStep'](this['_executionId'],{'id':_0x6b59c0,'parentStepId':_0x1ea163,'branchKey':null!==(_0x3bdace=_0x315dd9['branchKey'])&&void 0x0!==_0x3bdace?_0x3bdace:null,'siblingIndex':null!==(_0x4b630d=_0x315dd9['siblingIndex'])&&void 0x0!==_0x4b630d?_0x4b630d:null,'agentName':_0x404cd3,'kind':_0x404cd3,'type':STEP_TYPE_AGENT,'label':_0x404cd3,'status':_0x4a70c9,'latencyMs':Date['now']()-_0x57626c,'model':null!==(_0x35b8f4=null==_0x40ad09?void 0x0:_0x40ad09['model'])&&void 0x0!==_0x35b8f4?_0x35b8f4:null,'provider':null!==(_0x369354=null==_0x40ad09?void 0x0:_0x40ad09['provider'])&&void 0x0!==_0x369354?_0x369354:null,'input':snapshot(_0x3fe68c),'output':snapshot(_0x45234c),'state':snapshot(this['state']),'error':_0x4dd2c0}),this['rootStepId']=_0x6b59c0,'ok'!==_0x4a70c9||this['_currentStepId']||(this['_chainHeadStepId']=_0x6b59c0);}}}async['runAgent'](_0x407ea,_0x19f74e={}){const {output:_0x2c1f7d,stepId:_0x10adf9,edgeStepId:_0x4c8756}=await this['_runAgentObserved'](_0x407ea,_0x19f74e);if(!this['_currentStepId']){const _0x10399f=null!=_0x4c8756?_0x4c8756:_0x10adf9;_0x10399f&&this['_markTerminalSteps']([_0x10399f]);}return _0x2c1f7d;}async['waitForMessage'](_0x15216a={}){if(!this['notifier']||'function'!=typeof this['notifier']['_waitForInboundMessage'])throw new WorkflowError('waitForMessage\x20requires\x20a\x20DNotifier\x20instance');return this['notifier']['_waitForInboundMessage']({'timeoutMs':_0x15216a['timeoutMs']});}async['runAgents'](_0xae4bd8,_0x12ca10={}){const _0x23feb0=normalizeRunAgentsSpec(_0xae4bd8),_0x100345=resolveRecordedParentStepId({'parentStepId':_0x12ca10['parentStepId'],'resolveParent':()=>this['_resolveParentStepId'](_0x12ca10)}),_0x46be33=await Promise['all'](_0x23feb0['map']((_0x4075be,_0x259c77)=>this['_runAgentObserved'](_0x4075be['name'],{'input':_0x4075be['input'],'parentStepId':_0x100345,'siblingIndex':_0x259c77}))),_0x59ed8a=_0x46be33['map'](_0x2d42c9=>_0x2d42c9['output']),_0x46831c=_0x46be33['map'](_0x5e78ac=>_0x5e78ac['stepId']),_0x44b40d=_0x46be33['map'](_0x29765b=>{var _0x53c2dc;return null!==(_0x53c2dc=_0x29765b['edgeStepId'])&&void 0x0!==_0x53c2dc?_0x53c2dc:_0x29765b['stepId'];});if(this['_markTerminalSteps'](_0x44b40d),Array['isArray'](_0xae4bd8))return{'results':_0x59ed8a,'stepIds':_0x46831c};const _0x56a064={};return _0x23feb0['forEach']((_0x3cb50e,_0x4d1c21)=>{_0x56a064[_0x3cb50e['key']]=_0x59ed8a[_0x4d1c21];}),{'results':_0x56a064,'stepIds':_0x46831c};}async['sendAI'](_0x5df945){var _0x40e67a,_0x46ecde,_0x144e55,_0xd0fad6,_0xa94384,_0x358c1a;const _0x65086f=null!==(_0x46ecde=null!==(_0x40e67a=null==_0x5df945?void 0x0:_0x5df945['provider'])&&void 0x0!==_0x40e67a?_0x40e67a:this['_aiProvider'])&&void 0x0!==_0x46ecde?_0x46ecde:void 0x0,_0x427a80=null!==(_0xd0fad6=null!==(_0x144e55=null==_0x5df945?void 0x0:_0x5df945['model'])&&void 0x0!==_0x144e55?_0x144e55:this['_aiModel'])&&void 0x0!==_0xd0fad6?_0xd0fad6:void 0x0,_0x1f0328=this['agentName']?this['workflow']['getAgent'](this['agentName']):void 0x0;return(null==_0x1f0328?void 0x0:_0x1f0328['hasTools'])?this['_invokeSdkApi']('sendAI',()=>{var _0x537b93,_0x4fc22f,_0x57a0fe,_0x2ca6db;return runAgentLoop({'notifier':this['notifier'],'agent':_0x1f0328,'input':null!==(_0x537b93=null==_0x5df945?void 0x0:_0x5df945['message'])&&void 0x0!==_0x537b93?_0x537b93:this['input'],'executionId':this['_executionId'],'userId':this['senderId'],'sessionId':null!==(_0x57a0fe=null!==(_0x4fc22f=null==_0x5df945?void 0x0:_0x5df945['sessionId'])&&void 0x0!==_0x4fc22f?_0x4fc22f:this['_sessionId'])&&void 0x0!==_0x57a0fe?_0x57a0fe:null,'checkpointer':null!==(_0x2ca6db=this['_checkpointer'])&&void 0x0!==_0x2ca6db?_0x2ca6db:null,'signal':null==_0x5df945?void 0x0:_0x5df945['signal'],'maxToolRounds':null==_0x5df945?void 0x0:_0x5df945['maxToolRounds'],'provider':_0x65086f,'model':_0x427a80,'metadata':null==_0x5df945?void 0x0:_0x5df945['metadata'],'middlewareCtx':this,'trace':workflowTraceFromContext(this)});},{'label':null==_0x5df945?void 0x0:_0x5df945['label'],'input':null!==(_0xa94384=null==_0x5df945?void 0x0:_0x5df945['message'])&&void 0x0!==_0xa94384?_0xa94384:apiInput(_0x5df945),'usesTokens':!0x0,'provider':_0x65086f,'model':_0x427a80}):this['_invokeSdkApi']('sendAI',()=>this['notifier']['sendAI']({'senderId':this['senderId'],..._0x5df945,'provider':_0x65086f,'model':_0x427a80}),{'label':null==_0x5df945?void 0x0:_0x5df945['label'],'input':null!==(_0x358c1a=null==_0x5df945?void 0x0:_0x5df945['message'])&&void 0x0!==_0x358c1a?_0x358c1a:apiInput(_0x5df945),'usesTokens':!0x0,'provider':_0x65086f,'model':_0x427a80});}async['fetchAIHistory'](_0x72c943={}){return this['_invokeSdkApi']('fetchAIHistory',()=>this['notifier']['fetchAIHistory']({'senderId':this['senderId'],..._0x72c943}),{'label':null==_0x72c943?void 0x0:_0x72c943['label'],'input':apiInput(_0x72c943)});}async['search'](_0x1e64df){return this['_invokeSdkApi']('search',()=>this['notifier']['search']({'senderId':this['senderId'],..._0x1e64df}),{'label':null==_0x1e64df?void 0x0:_0x1e64df['label'],'input':apiInput(_0x1e64df)});}async['addDocument'](_0xc2e4f4){return this['_invokeSdkApi']('addDocument',()=>this['notifier']['addDocument']({'senderId':this['senderId'],..._0xc2e4f4}),{'label':null==_0xc2e4f4?void 0x0:_0xc2e4f4['label'],'input':apiInput(_0xc2e4f4)});}async['updateDocument'](_0x16f456){return this['_invokeSdkApi']('updateDocument',()=>this['notifier']['updateDocument']({'senderId':this['senderId'],..._0x16f456}),{'label':null==_0x16f456?void 0x0:_0x16f456['label'],'input':apiInput(_0x16f456)});}async['deleteDocument'](_0x352c8e){return this['_invokeSdkApi']('deleteDocument',()=>this['notifier']['deleteDocument']({'senderId':this['senderId'],..._0x352c8e}),{'label':null==_0x352c8e?void 0x0:_0x352c8e['label'],'input':apiInput(_0x352c8e)});}async['listDocuments'](_0x32fb0a={}){return this['_invokeSdkApi']('listDocuments',()=>this['notifier']['listDocuments']({'senderId':this['senderId'],..._0x32fb0a}),{'label':null==_0x32fb0a?void 0x0:_0x32fb0a['label'],'input':apiInput(_0x32fb0a)});}async['getDocument'](_0x24a6ab){return this['_invokeSdkApi']('getDocument',()=>this['notifier']['getDocument']({'senderId':this['senderId'],..._0x24a6ab}),{'label':null==_0x24a6ab?void 0x0:_0x24a6ab['label'],'input':apiInput(_0x24a6ab)});}async['recordStep'](_0x5b74a4){var _0x5faa0c,_0x599d7b,_0x47d417,_0x237f94,_0x31ec79,_0x1c728b,_0xf8e6b,_0x1bf44f,_0xb130cc,_0x4b70c5,_0x34c9f1,_0x49266a;if(!this['_observabilityEnabled'])return;const _0x59d3ac=null!=_0x5b74a4['type']?toLogStepType(_0x5b74a4['type']):STEP_TYPE_CUSTOM;await this['_observability']['recordStep'](this['_executionId'],{..._0x5b74a4,'apiName':null!==(_0x5faa0c=_0x5b74a4['apiName'])&&void 0x0!==_0x5faa0c?_0x5faa0c:_0x5b74a4['kind'],'agentName':null!==(_0x599d7b=_0x5b74a4['agentName'])&&void 0x0!==_0x599d7b?_0x599d7b:this['agentName'],'kind':null!==(_0x31ec79=null!==(_0x237f94=null!==(_0x47d417=_0x5b74a4['agentName'])&&void 0x0!==_0x47d417?_0x47d417:this['agentName'])&&void 0x0!==_0x237f94?_0x237f94:_0x5b74a4['kind'])&&void 0x0!==_0x31ec79?_0x31ec79:'custom','type':_0x59d3ac,'label':null!==(_0x1c728b=_0x5b74a4['label'])&&void 0x0!==_0x1c728b?_0x1c728b:_0x59d3ac,'tokensIn':null!==(_0xf8e6b=_0x5b74a4['tokensIn'])&&void 0x0!==_0xf8e6b?_0xf8e6b:0x0,'tokensOut':null!==(_0x1bf44f=_0x5b74a4['tokensOut'])&&void 0x0!==_0x1bf44f?_0x1bf44f:0x0,'model':null!==(_0xb130cc=_0x5b74a4['model'])&&void 0x0!==_0xb130cc?_0xb130cc:null,'latencyMs':null!==(_0x4b70c5=_0x5b74a4['latencyMs'])&&void 0x0!==_0x4b70c5?_0x4b70c5:0x0,'status':null!==(_0x34c9f1=_0x5b74a4['status'])&&void 0x0!==_0x34c9f1?_0x34c9f1:'ok','error':null!==(_0x49266a=_0x5b74a4['error'])&&void 0x0!==_0x49266a?_0x49266a:null,'parentStepId':null!=_0x5b74a4['parentStepId']?formatParentStepId(_0x5b74a4['parentStepId']):formatParentStepId(this['_currentStepId']),'input':snapshot(_0x5b74a4['input']),'output':snapshot(_0x5b74a4['output']),'state':snapshot(void 0x0!==_0x5b74a4['state']?_0x5b74a4['state']:this['state'])});}}
@@ -1 +1 @@
1
- export class WorkflowError extends Error{constructor(_0x2e647f,_0xa02ad7={}){super(_0x2e647f),this['name']='WorkflowError',this['agentName']=_0xa02ad7['agentName'],_0xa02ad7['cause']&&(this['cause']=_0xa02ad7['cause']);}}
1
+ export class WorkflowError extends Error{constructor(_0x5b3346,_0x1f32dc={}){super(_0x5b3346),this['name']='WorkflowError',this['agentName']=_0x1f32dc['agentName'],_0x1f32dc['cause']&&(this['cause']=_0x1f32dc['cause']);}}
@@ -1 +1 @@
1
- export function formatParentStepId(_0xcc1779){if(null==_0xcc1779)return null;if(Array['isArray'](_0xcc1779)){const _0x2a2808=_0xcc1779['filter'](_0x32a1d8=>null!=_0x32a1d8&&''!==String(_0x32a1d8)['trim']());return _0x2a2808['length']>0x0?_0x2a2808['join'](','):null;}const _0x362173=String(_0xcc1779)['trim']();return''===_0x362173?null:_0x362173;}export function resolveGraphParentStepId(_0x2600b4){var _0x5d27b5;const _0x13f353=null!==(_0x5d27b5=_0x2600b4['parentStepIds'])&&void 0x0!==_0x5d27b5?_0x5d27b5:_0x2600b4['dependsOn'];return(null==_0x13f353?void 0x0:_0x13f353['length'])?formatParentStepId(_0x13f353):formatParentStepId(_0x2600b4['parentStepId']);}export function resolveRecordedParentStepId(_0x43c1b0={}){var _0x24d248;const _0xa02bbc=null!==(_0x24d248=_0x43c1b0['parentStepIds'])&&void 0x0!==_0x24d248?_0x24d248:_0x43c1b0['dependsOn'];return(null==_0xa02bbc?void 0x0:_0xa02bbc['length'])?formatParentStepId(_0xa02bbc):void 0x0!==_0x43c1b0['parentStepId']?formatParentStepId(_0x43c1b0['parentStepId']):_0x43c1b0['resolveParent']?formatParentStepId(_0x43c1b0['resolveParent']()):null;}
1
+ export function formatParentStepId(_0x30628a){if(null==_0x30628a)return null;if(Array['isArray'](_0x30628a)){const _0x462fc3=_0x30628a['filter'](_0x4e9fbc=>null!=_0x4e9fbc&&''!==String(_0x4e9fbc)['trim']());return _0x462fc3['length']>0x0?_0x462fc3['join'](','):null;}const _0x4fd4dd=String(_0x30628a)['trim']();return''===_0x4fd4dd?null:_0x4fd4dd;}export function resolveGraphParentStepId(_0x2473a6){var _0x177c8a;const _0x23ddbe=null!==(_0x177c8a=_0x2473a6['parentStepIds'])&&void 0x0!==_0x177c8a?_0x177c8a:_0x2473a6['dependsOn'];return(null==_0x23ddbe?void 0x0:_0x23ddbe['length'])?formatParentStepId(_0x23ddbe):formatParentStepId(_0x2473a6['parentStepId']);}export function resolveRecordedParentStepId(_0x4f4112={}){var _0x4a457d;const _0x2bac7d=null!==(_0x4a457d=_0x4f4112['parentStepIds'])&&void 0x0!==_0x4a457d?_0x4a457d:_0x4f4112['dependsOn'];return(null==_0x2bac7d?void 0x0:_0x2bac7d['length'])?formatParentStepId(_0x2bac7d):void 0x0!==_0x4f4112['parentStepId']?formatParentStepId(_0x4f4112['parentStepId']):_0x4f4112['resolveParent']?formatParentStepId(_0x4f4112['resolveParent']()):null;}
@@ -1 +1 @@
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
+ export function randomUUID(){const _0x3dd5b0='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x3dd5b0&&'function'==typeof _0x3dd5b0['randomUUID'])return _0x3dd5b0['randomUUID']();if(_0x3dd5b0&&_0x3dd5b0['getRandomValues']){const _0x4dbbe1=new Uint8Array(0x10);_0x3dd5b0['getRandomValues'](_0x4dbbe1),_0x4dbbe1[0x6]=0xf&_0x4dbbe1[0x6]|0x40,_0x4dbbe1[0x8]=0x3f&_0x4dbbe1[0x8]|0x80;const _0xc18b86=[..._0x4dbbe1]['map'](_0x8103f=>_0x8103f['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0xc18b86['slice'](0x0,0x8)+'-'+_0xc18b86['slice'](0x8,0xc)+'-'+_0xc18b86['slice'](0xc,0x10)+'-'+_0xc18b86['slice'](0x10,0x14)+'-'+_0xc18b86['slice'](0x14);}return'id_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function shortId(_0x13ac00){return _0x13ac00+'_'+randomUUID()['replace'](/-/g,'')['slice'](0x0,0xc);}
@@ -1 +1 @@
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
+ export function toJsonColumn(_0x1d1538){if(null==_0x1d1538)return null;if('string'==typeof _0x1d1538){const _0x441215=_0x1d1538['trim']();if(''===_0x441215)return{};if(_0x441215['startsWith']('{')||_0x441215['startsWith']('['))try{return JSON['parse'](_0x441215);}catch{return{'text':_0x1d1538};}return{'text':_0x1d1538};}if('number'==typeof _0x1d1538||'boolean'==typeof _0x1d1538)return _0x1d1538;try{return JSON['parse'](JSON['stringify'](_0x1d1538,(_0x2a9a4f,_0x3e8123)=>'bigint'==typeof _0x3e8123?_0x3e8123['toString']():_0x3e8123));}catch{return{'text':String(_0x1d1538)};}}export function setJsonColumn(_0x85d882,_0x3c5677,_0x4ec596){const _0xf58896=toJsonColumn(_0x4ec596);null!==_0xf58896&&(_0x85d882[_0x3c5677]=_0xf58896);}
@@ -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:_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
+ 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:_0x2a6154=null,token:_0x1a28e1=null,httpEnabled:_0x2171ac=!0x1}={}){this['appId']=_0x2a6154,this['token']=_0x1a28e1,this['httpEnabled']=Boolean(_0x2171ac),this['workflows']=globalMockStore['workflows'],this['executions']=globalMockStore['executions'],this['stepsByExecution']=globalMockStore['stepsByExecution'],this['errorCountByWorkflow']=globalMockStore['errorCountByWorkflow'];}['configure']({appId:_0xcdb395,token:_0x94f2eb}={}){void 0x0!==_0xcdb395&&(this['appId']=_0xcdb395),void 0x0!==_0x94f2eb&&(this['token']=_0x94f2eb);}['_transport'](_0x3f32de){const _0x51868e=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x3f32de,'headers':_0x51868e});}async['_maybeHttp'](_0x3d5287,_0x362bc8,_0xf3cb1d){var _0x20b8b5;if(this['httpEnabled'])try{const _0x67bb01=this['_transport'](_0x362bc8);'POST'===_0x3d5287&&await _0x67bb01['send'](_0xf3cb1d);}catch(_0x15dd0e){console['warn']('[WorkflowObservability]\x20mock\x20HTTP\x20failed:',null!==(_0x20b8b5=null==_0x15dd0e?void 0x0:_0x15dd0e['message'])&&void 0x0!==_0x20b8b5?_0x20b8b5:_0x15dd0e);}}async['registerWorkflow'](_0x4e9927){var _0x4ab211;const _0x4264e7=(null!==(_0x4ab211=this['appId'])&&void 0x0!==_0x4ab211?_0x4ab211:'app')+':'+_0x4e9927['workflowId'];return this['workflows']['has'](_0x4264e7)||this['workflows']['set'](_0x4264e7,{..._0x4e9927,'registeredAt':new Date()['toISOString']()}),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockRegisterUrl'],_0x4e9927),{'ok':!0x0};}async['createExecution'](_0x7e61eb){var _0x5bdc1b;const _0x46b8a4=null!==(_0x5bdc1b=_0x7e61eb['id'])&&void 0x0!==_0x5bdc1b?_0x5bdc1b:shortId('exec'),_0x5d13c4={..._0x7e61eb,'id':_0x46b8a4,'status':'in_progress','stepCount':0x0,'steps':[]};return this['executions']['set'](_0x46b8a4,_0x5d13c4),this['stepsByExecution']['set'](_0x46b8a4,[]),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionsUrl'],_0x5d13c4),{'executionId':_0x46b8a4,'record':_0x5d13c4};}async['updateExecution'](_0x58ec24,_0x2aa0c7){var _0x4223de;const _0x26ec24=this['executions']['get'](_0x58ec24);if(!_0x26ec24)return{'ok':!0x1};const _0x48f31c={..._0x26ec24,..._0x2aa0c7};if(this['executions']['set'](_0x58ec24,_0x48f31c),'error'===_0x2aa0c7['status']&&_0x48f31c['workflowId']){const _0x5c1349=_0x48f31c['workflowId'];this['errorCountByWorkflow']['set'](_0x5c1349,(null!==(_0x4223de=this['errorCountByWorkflow']['get'](_0x5c1349))&&void 0x0!==_0x4223de?_0x4223de:0x0)+0x1);}return await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockExecutionUrl'](_0x58ec24),_0x48f31c),{'ok':!0x0,'record':_0x48f31c};}async['addStep'](_0x1c2638,_0x29e66c){var _0x30e525,_0x2ba4ce;const _0x57c1a1=null!==(_0x30e525=this['stepsByExecution']['get'](_0x1c2638))&&void 0x0!==_0x30e525?_0x30e525:[];_0x57c1a1['push'](_0x29e66c),this['stepsByExecution']['set'](_0x1c2638,_0x57c1a1);const _0x33fb97=this['executions']['get'](_0x1c2638);return _0x33fb97&&(_0x33fb97['stepCount']=_0x57c1a1['length'],_0x33fb97['steps']=_0x57c1a1,this['executions']['set'](_0x1c2638,_0x33fb97)),'error'===_0x29e66c['status']&&(null==_0x33fb97?void 0x0:_0x33fb97['workflowId'])&&this['errorCountByWorkflow']['set'](_0x33fb97['workflowId'],(null!==(_0x2ba4ce=this['errorCountByWorkflow']['get'](_0x33fb97['workflowId']))&&void 0x0!==_0x2ba4ce?_0x2ba4ce:0x0)+0x1),await this['_maybeHttp']('POST',DNotifierEndpoints['workflowMockStepsUrl'](_0x1c2638),_0x29e66c),{'ok':!0x0};}['getDashboardSnapshot'](){return{'totalWorkflows':this['workflows']['size'],'executions':[...this['executions']['values']()],'stepsByExecution':Object['fromEntries'](this['stepsByExecution']),'errorCountByWorkflow':Object['fromEntries'](this['errorCountByWorkflow'])};}}
@@ -16,16 +16,19 @@ export class WorkflowObservability {
16
16
  _registeredWorkflowNames: Set<string>;
17
17
  _stepCounter: number;
18
18
  _appendOnly: boolean;
19
+ _sessionId: string | null;
19
20
  allocateStepId(): string;
20
21
  registerWorkflow(workflow: import("./workflow.js").Workflow): Promise<void>;
21
22
  startExecution(params: object): Promise<{
22
23
  executionId: string;
23
24
  startedAt: any;
24
25
  startedAtMs: any;
26
+ sessionId: string | null;
25
27
  }>;
26
28
  recordStep(executionId: string, step: object): Promise<{
27
29
  id: any;
28
30
  executionId: string;
31
+ sessionId: string | null;
29
32
  executedAt: any;
30
33
  apiName: any;
31
34
  agentName: any;
@@ -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:_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
+ 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:_0x6d2b86,token:_0x4c0dcc=null,client:_0x5ba493,appendOnly:_0x32bca6=!0x1}){this['appId']=_0x6d2b86,this['token']=_0x4c0dcc,this['client']=null!=_0x5ba493?_0x5ba493:new WorkflowObservabilityClient({'appId':_0x6d2b86,'token':_0x4c0dcc}),this['client']['configure']({'appId':_0x6d2b86,'token':_0x4c0dcc}),this['_registeredWorkflowNames']=new Set(),this['_stepCounter']=0x0,this['_appendOnly']=Boolean(_0x32bca6),this['_sessionId']=null;}['allocateStepId'](){return shortId('step');}async['registerWorkflow'](_0x27ec11){var _0x325247;if(!this['_registeredWorkflowNames']['has'](_0x27ec11['name'])){this['_registeredWorkflowNames']['add'](_0x27ec11['name']);try{await this['client']['registerWorkflow']({'appId':this['appId'],'workflowId':_0x27ec11['name'],'name':_0x27ec11['name'],'description':null!==(_0x325247=_0x27ec11['description'])&&void 0x0!==_0x325247?_0x325247:null});}catch{}}}async['startExecution'](_0x9ca7f7){var _0x46605d,_0x2758a6,_0x57f885,_0x4fcad5;if(this['_appendOnly'])throw new Error('startExecution\x20is\x20not\x20allowed\x20in\x20append-only\x20workflow\x20observability\x20mode');const _0x175b7a=shortId('exec');this['_sessionId']=null!=_0x9ca7f7['sessionId']&&''!==String(_0x9ca7f7['sessionId'])['trim']()?String(_0x9ca7f7['sessionId']):null;const _0x3b0290='number'==typeof _0x9ca7f7['startedAtMs']&&Number['isFinite'](_0x9ca7f7['startedAtMs'])?_0x9ca7f7['startedAtMs']:Date['now'](),_0x2d9adb='string'==typeof _0x9ca7f7['startedAt']&&_0x9ca7f7['startedAt']['trim']()?_0x9ca7f7['startedAt']:new Date(_0x3b0290)['toISOString']();try{await this['client']['createExecution']({'id':_0x175b7a,'appId':this['appId'],'workflowId':_0x9ca7f7['workflowId'],'userId':_0x9ca7f7['userId'],'sessionId':this['_sessionId'],'mode':null!==(_0x46605d=_0x9ca7f7['mode'])&&void 0x0!==_0x46605d?_0x46605d:void 0x0,'parentExecutionId':null!==(_0x2758a6=_0x9ca7f7['parentExecutionId'])&&void 0x0!==_0x2758a6?_0x2758a6:void 0x0,'fromCheckpointId':null!==(_0x57f885=_0x9ca7f7['fromCheckpointId'])&&void 0x0!==_0x57f885?_0x57f885:void 0x0,'input':null!==(_0x4fcad5=_0x9ca7f7['input'])&&void 0x0!==_0x4fcad5?_0x4fcad5:null,'startedAt':_0x2d9adb});}catch{}return this['_stepCounter']=0x0,{'executionId':_0x175b7a,'startedAt':_0x2d9adb,'startedAtMs':_0x3b0290,'sessionId':this['_sessionId']};}async['recordStep'](_0x132b1c,_0x32d786){var _0x51bec4,_0x5cbf98,_0x3b5a22,_0x512345,_0x589dfc,_0x451272,_0x48fb61,_0x165f9e,_0x375e44;if(!_0x132b1c)return null;this['_stepCounter']+=0x1;const _0x635245=null!==(_0x51bec4=_0x32d786['id'])&&void 0x0!==_0x51bec4?_0x51bec4:this['allocateStepId'](),_0xe239ac=resolveStepType(_0x32d786),_0x1deb44=null!==(_0x512345=null!==(_0x3b5a22=null!==(_0x5cbf98=_0x32d786['agentName'])&&void 0x0!==_0x5cbf98?_0x5cbf98:_0x32d786['kind'])&&void 0x0!==_0x3b5a22?_0x3b5a22:_0x32d786['apiName'])&&void 0x0!==_0x512345?_0x512345:null,_0x500877=resolveGraphParentStepId(_0x32d786),_0x59e2ab=null!=_0x32d786['sessionId']&&''!==String(_0x32d786['sessionId'])['trim']()?String(_0x32d786['sessionId']):this['_sessionId'],_0x2b4876={..._0x32d786,'id':_0x635245,'executionId':_0x132b1c,'sessionId':_0x59e2ab,'executedAt':null!==(_0x589dfc=_0x32d786['executedAt'])&&void 0x0!==_0x589dfc?_0x589dfc:new Date()['toISOString'](),'apiName':null!==(_0x451272=_0x32d786['apiName'])&&void 0x0!==_0x451272?_0x451272:null,'agentName':null!==(_0x48fb61=_0x32d786['agentName'])&&void 0x0!==_0x48fb61?_0x48fb61:null,'kind':_0x1deb44,'type':_0xe239ac,'step_type':_0xe239ac,'parentStepId':_0x500877,'siblingIndex':null!==(_0x165f9e=_0x32d786['siblingIndex'])&&void 0x0!==_0x165f9e?_0x165f9e:null,'branchKey':null!==(_0x375e44=_0x32d786['branchKey'])&&void 0x0!==_0x375e44?_0x375e44:null};delete _0x2b4876['dependsOn'],delete _0x2b4876['parentStepIds'];try{await this['client']['addStep'](_0x132b1c,_0x2b4876);}catch{}return _0x2b4876;}async['completeExecution'](_0x18cc63){var _0x1f7cff,_0x27b372,_0x2301b7,_0x10fbdf;if(_0x18cc63['executionId']){if(this['_appendOnly'])try{await this['client']['updateExecution'](_0x18cc63['executionId'],{'stepCount':null!==(_0x1f7cff=_0x18cc63['stepCount'])&&void 0x0!==_0x1f7cff?_0x1f7cff:this['_stepCounter']});}catch{}else try{await this['client']['updateExecution'](_0x18cc63['executionId'],{'status':_0x18cc63['status'],'endedAt':_0x18cc63['endedAt'],'durationMs':_0x18cc63['durationMs'],'stepCount':_0x18cc63['stepCount'],'error':null!==(_0x27b372=_0x18cc63['error'])&&void 0x0!==_0x27b372?_0x27b372:null,'result':null!==(_0x2301b7=_0x18cc63['result'])&&void 0x0!==_0x2301b7?_0x2301b7:null,'sessionId':null!==(_0x10fbdf=_0x18cc63['sessionId'])&&void 0x0!==_0x10fbdf?_0x10fbdf:this['_sessionId']});}catch{}}}['getStepCount'](){return this['_stepCounter'];}}export function createWorkflowObservability(_0x11f622){return new WorkflowObservability(_0x11f622);}
@@ -7,10 +7,18 @@ export function invokeRemoteAgent(params: {
7
7
  input?: any;
8
8
  state?: object;
9
9
  trace?: object | null;
10
+ sessionId?: string | null;
11
+ fromCheckpointId?: string | null;
12
+ mode?: string | null;
13
+ resume?: boolean;
10
14
  timeoutMs?: number;
11
15
  }): Promise<{
12
16
  output: any;
13
17
  state: object | null;
18
+ sessionId?: string | null;
19
+ checkpointId?: string | null;
20
+ executionId?: string | null;
21
+ mode?: string | null;
14
22
  }>;
15
23
  export function sendRemoteAgentResult(notifier: import("../dnotifier.js").DNotifier, params: {
16
24
  senderId: string;
@@ -19,6 +27,10 @@ export function sendRemoteAgentResult(notifier: import("../dnotifier.js").DNotif
19
27
  agentName?: string;
20
28
  output?: any;
21
29
  state?: object | null;
30
+ sessionId?: string | null;
31
+ checkpointId?: string | null;
32
+ executionId?: string | null;
33
+ mode?: string | null;
22
34
  }): Promise<void>;
23
35
  export function sendRemoteAgentError(notifier: import("../dnotifier.js").DNotifier, params: {
24
36
  senderId: string;
@@ -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 _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
+ import{WorkflowError}from'./errors.js';import{createErrorEnvelope,createInvokeEnvelope,createResultEnvelope,REMOTE_AGENT_OP}from'./remoteAgentProtocol.js';const DEFAULT_TIMEOUT_MS=0x1d4c0;function correlationId(){const _0x197f84='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x197f84&&'function'==typeof _0x197f84['randomUUID'])return _0x197f84['randomUUID']();if(_0x197f84&&_0x197f84['getRandomValues']){const _0x458eaa=new Uint8Array(0x10);_0x197f84['getRandomValues'](_0x458eaa),_0x458eaa[0x6]=0xf&_0x458eaa[0x6]|0x40,_0x458eaa[0x8]=0x3f&_0x458eaa[0x8]|0x80;const _0x5d29f9=[..._0x458eaa]['map'](_0x2eac08=>_0x2eac08['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x5d29f9['slice'](0x0,0x8)+'-'+_0x5d29f9['slice'](0x8,0xc)+'-'+_0x5d29f9['slice'](0xc,0x10)+'-'+_0x5d29f9['slice'](0x10,0x14)+'-'+_0x5d29f9['slice'](0x14);}return'corr_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function bareUserId(_0x3243bc,_0x2f30f2){if(!_0x2f30f2||'string'!=typeof _0x2f30f2)return'';const _0x32c5cf=_0x3243bc+':';if(_0x2f30f2['startsWith'](_0x32c5cf))return _0x2f30f2['slice'](_0x32c5cf['length']);const _0x5cbdba=_0x2f30f2['indexOf'](':');return _0x5cbdba>=0x0?_0x2f30f2['slice'](_0x5cbdba+0x1):_0x2f30f2;}export async function invokeRemoteAgent(_0x4faeca){const {notifier:_0x37d088,senderId:_0x30facd,receiverId:_0x4de2b0,agentName:_0x1a8ed8,input:_0x2be076,state:_0x47e579,trace:_0x100a7b=null,sessionId:_0x1c2e3f=null,fromCheckpointId:_0x2fe85e=null,mode:_0x457c25=null,resume:_0x53922a,timeoutMs:_0x307286=DEFAULT_TIMEOUT_MS}=_0x4faeca;if(!(null==_0x37d088?void 0x0:_0x37d088['isConnected']))throw new WorkflowError('Remote\x20agent\x20invoke\x20requires\x20a\x20connected\x20notifier');if(!_0x4de2b0)throw new WorkflowError('Remote\x20agent\x20\x22'+_0x1a8ed8+'\x22\x20is\x20missing\x20receiverId');const _0x2bdbac=correlationId(),_0x3a5754=createInvokeEnvelope({'correlationId':_0x2bdbac,'agentName':_0x1a8ed8,'input':_0x2be076,'state':null!=_0x47e579?_0x47e579:null,'trace':_0x100a7b,'replyTo':_0x30facd,'sessionId':_0x1c2e3f,'fromCheckpointId':_0x2fe85e,'mode':_0x457c25,'resume':_0x53922a}),_0x243aff=_0x37d088['_awaitRemoteAgentReply'](_0x2bdbac,{'timeoutMs':_0x307286,'agentName':_0x1a8ed8});return await _0x37d088['send']({'senderId':_0x30facd,'receiverId':_0x4de2b0,'data':_0x3a5754,'saveHistory':!0x1}),_0x243aff;}export async function sendRemoteAgentResult(_0x43f59a,_0x1dd5d2){var _0x57a14c;await _0x43f59a['send']({'senderId':_0x1dd5d2['senderId'],'receiverId':_0x1dd5d2['receiverId'],'data':createResultEnvelope({'correlationId':_0x1dd5d2['correlationId'],'agentName':_0x1dd5d2['agentName'],'output':_0x1dd5d2['output'],'state':null!==(_0x57a14c=_0x1dd5d2['state'])&&void 0x0!==_0x57a14c?_0x57a14c:null,'sessionId':_0x1dd5d2['sessionId'],'checkpointId':_0x1dd5d2['checkpointId'],'executionId':_0x1dd5d2['executionId'],'mode':_0x1dd5d2['mode']}),'saveHistory':!0x1});}export async function sendRemoteAgentError(_0x3bbfcb,_0xa971b5){await _0x3bbfcb['send']({'senderId':_0xa971b5['senderId'],'receiverId':_0xa971b5['receiverId'],'data':createErrorEnvelope({'correlationId':_0xa971b5['correlationId'],'agentName':_0xa971b5['agentName'],'message':_0xa971b5['message']}),'saveHistory':!0x1});}export function isRemoteAgentReply(_0x110ae4){return null!=_0x110ae4&&'object'==typeof _0x110ae4&&(_0x110ae4['op']===REMOTE_AGENT_OP['RESULT']||_0x110ae4['op']===REMOTE_AGENT_OP['ERROR']);}export{DEFAULT_TIMEOUT_MS};
@@ -9,6 +9,10 @@ export function createInvokeEnvelope(params: {
9
9
  state?: object | null;
10
10
  trace?: object | null;
11
11
  replyTo: string;
12
+ sessionId?: string | null;
13
+ fromCheckpointId?: string | null;
14
+ mode?: string | null;
15
+ resume?: boolean;
12
16
  }): {
13
17
  __dnotifier: string;
14
18
  op: string;
@@ -24,6 +28,10 @@ export function createResultEnvelope(params: {
24
28
  agentName?: string;
25
29
  output?: any;
26
30
  state?: object | null;
31
+ sessionId?: string | null;
32
+ checkpointId?: string | null;
33
+ executionId?: string | null;
34
+ mode?: string | null;
27
35
  }): {
28
36
  __dnotifier: string;
29
37
  op: string;
@@ -1 +1 @@
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;}
1
+ export const REMOTE_AGENT_KIND='dnotifier.remoteAgent';export const REMOTE_AGENT_OP={'INVOKE':'invoke','RESULT':'result','ERROR':'error'};export function isRemoteAgentEnvelope(_0x1b8137){return null!=_0x1b8137&&'object'==typeof _0x1b8137&&_0x1b8137['__dnotifier']===REMOTE_AGENT_KIND&&'string'==typeof _0x1b8137['op'];}export function isRemoteAgentRef(_0x5a3f70){return null!=_0x5a3f70&&'object'==typeof _0x5a3f70&&'string'==typeof _0x5a3f70['receiverId']&&''!==_0x5a3f70['receiverId']['trim']()&&'function'!=typeof _0x5a3f70['run'];}export function createInvokeEnvelope(_0x2ab16f){var _0x10edfd,_0x296de7,_0x46a03f;const _0x521236={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['INVOKE'],'correlationId':_0x2ab16f['correlationId'],'agentName':_0x2ab16f['agentName'],'input':null!==(_0x10edfd=_0x2ab16f['input'])&&void 0x0!==_0x10edfd?_0x10edfd:null,'state':null!==(_0x296de7=_0x2ab16f['state'])&&void 0x0!==_0x296de7?_0x296de7:null,'trace':null!==(_0x46a03f=_0x2ab16f['trace'])&&void 0x0!==_0x46a03f?_0x46a03f:null,'replyTo':_0x2ab16f['replyTo']};return null!=_0x2ab16f['sessionId']&&''!==String(_0x2ab16f['sessionId'])['trim']()&&(_0x521236['sessionId']=String(_0x2ab16f['sessionId'])),null!=_0x2ab16f['fromCheckpointId']&&''!==String(_0x2ab16f['fromCheckpointId'])['trim']()&&(_0x521236['fromCheckpointId']=String(_0x2ab16f['fromCheckpointId'])),null!=_0x2ab16f['mode']&&''!==String(_0x2ab16f['mode'])['trim']()&&(_0x521236['mode']=String(_0x2ab16f['mode'])),!0x0===_0x2ab16f['resume']&&(_0x521236['resume']=!0x0),_0x521236;}export function createResultEnvelope(_0x27380b){var _0x4f3685,_0x429fe4;const _0x37fe8d={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['RESULT'],'correlationId':_0x27380b['correlationId']};return _0x27380b['agentName']&&(_0x37fe8d['agentName']=_0x27380b['agentName']),_0x37fe8d['output']=null!==(_0x4f3685=_0x27380b['output'])&&void 0x0!==_0x4f3685?_0x4f3685:null,_0x37fe8d['state']=null!==(_0x429fe4=_0x27380b['state'])&&void 0x0!==_0x429fe4?_0x429fe4:null,null!=_0x27380b['sessionId']&&''!==String(_0x27380b['sessionId'])['trim']()&&(_0x37fe8d['sessionId']=String(_0x27380b['sessionId'])),null!=_0x27380b['checkpointId']&&''!==String(_0x27380b['checkpointId'])['trim']()&&(_0x37fe8d['checkpointId']=String(_0x27380b['checkpointId'])),null!=_0x27380b['executionId']&&''!==String(_0x27380b['executionId'])['trim']()&&(_0x37fe8d['executionId']=String(_0x27380b['executionId'])),null!=_0x27380b['mode']&&''!==String(_0x27380b['mode'])['trim']()&&(_0x37fe8d['mode']=String(_0x27380b['mode'])),_0x37fe8d;}export function createErrorEnvelope(_0x2d130a){const _0xe8e702={'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['ERROR'],'correlationId':_0x2d130a['correlationId']};return _0x2d130a['agentName']&&(_0xe8e702['agentName']=_0x2d130a['agentName']),_0xe8e702['error']={'message':_0x2d130a['message']},_0xe8e702;}
@@ -9,9 +9,19 @@ export class WorkflowRunner {
9
9
  workflow: import("./workflow.js").Workflow;
10
10
  run(params: {
11
11
  input: any;
12
+ sessionId?: string | null;
13
+ checkpointer?: any;
14
+ mode?: string | null;
15
+ resume?: boolean;
16
+ fromCheckpointId?: string | null;
12
17
  }): Promise<{
18
+ result: any;
19
+ state: any;
20
+ mode: "resume" | "run" | "retry";
21
+ } | {
13
22
  result: unknown;
14
- state: {};
23
+ state: any;
24
+ mode: "resume" | "run" | "retry" | "replay";
15
25
  }>;
16
26
  }
17
27
  //# sourceMappingURL=runner.d.ts.map
@@ -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';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
+ 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';import{resolveRunSession,safeCheckpointPut,finalizeExecutionCheckpoints,normalizeRunMode,loadSourceCheckpoint,resumeCursor,resolveExecutionInput}from'../checkpoint/index.js';import{shortId}from'./ids.js';function snapshot(_0x126fc5){try{return void 0x0===_0x126fc5?null:JSON['parse'](JSON['stringify'](_0x126fc5));}catch{return String(_0x126fc5);}}export class WorkflowRunner{constructor({notifier:_0x305b6c,senderId:_0x32b16a,workflow:_0x3188ac}){if(!_0x305b6c)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20DNotifier\x20instance');if(!_0x32b16a)throw new WorkflowError('WorkflowRunner\x20requires\x20senderId');if(!_0x3188ac)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20workflow');this['notifier']=_0x305b6c,this['senderId']=_0x32b16a,this['workflow']=_0x3188ac;}async['run'](_0x411845){var _0x1e862d,_0x5bf554,_0x38fda5,_0x4a7fd7,_0x1187b6,_0x793a2d,_0x261502;const _0x20eff3=null==_0x411845?void 0x0:_0x411845['input'],_0x291ba9=Boolean(this['workflow']['observability']),{mode:_0x44b206,fromCheckpointId:_0x77f720,isContinuing:_0x896e0f}=normalizeRunMode(null!=_0x411845?_0x411845:{});if(_0x896e0f&&!(null==_0x411845?void 0x0:_0x411845['sessionId'])&&!_0x77f720)throw new WorkflowError('resume/retry/replay\x20requires\x20sessionId\x20or\x20fromCheckpointId');const _0x861133=void 0x0!==(null==_0x411845?void 0x0:_0x411845['checkpointer'])?_0x411845['checkpointer']:_0x896e0f&&!(null==_0x411845?void 0x0:_0x411845['sessionId'])?'remote':null==_0x411845?void 0x0:_0x411845['checkpointer'];let {checkpointer:_0x2586db,sessionId:_0x3c98ec}=resolveRunSession(this['notifier'],{'sessionId':null!==(_0x1e862d=null==_0x411845?void 0x0:_0x411845['sessionId'])&&void 0x0!==_0x1e862d?_0x1e862d:null,'checkpointer':_0x861133,'needTraceSession':_0x291ba9});const _0x479d77=_0x2586db&&(_0x3c98ec||_0x77f720)?await loadSourceCheckpoint(_0x2586db,{'sessionId':_0x3c98ec,'fromCheckpointId':_0x77f720}):null;if(_0x896e0f&&!_0x479d77)throw new WorkflowError(_0x77f720?'Checkpoint\x20not\x20found:\x20'+_0x77f720:'No\x20checkpoint\x20found\x20to\x20resume/retry/replay');_0x896e0f&&(null==_0x479d77?void 0x0:_0x479d77['sessionId'])&&!_0x3c98ec&&(_0x3c98ec=_0x479d77['sessionId']);const _0x349d02=resumeCursor(_0x479d77),_0x1ef3fb=_0x896e0f?_0x349d02['parentExecutionId']:null,_0x4391e0=_0x896e0f?null!=_0x77f720?_0x77f720:_0x349d02['fromCheckpointId']:null,_0x3a733e=(null===(_0x5bf554=null==_0x479d77?void 0x0:_0x479d77['state'])||void 0x0===_0x5bf554?void 0x0:_0x5bf554['workflowState'])&&'object'==typeof _0x479d77['state']['workflowState']&&!Array['isArray'](_0x479d77['state']['workflowState'])?{..._0x479d77['state']['workflowState']}:{};if(_0x896e0f&&'replay'!==_0x44b206&&'completed'===_0x349d02['phase']&&void 0x0!==_0x349d02['result']&&null!==_0x349d02['result']){const _0x38d10f={'result':_0x349d02['result'],'state':_0x3a733e,'mode':_0x44b206};return _0x3c98ec&&(_0x38d10f['sessionId']=_0x3c98ec),_0x349d02['fromCheckpointId']&&(_0x38d10f['checkpointId']=_0x349d02['fromCheckpointId']),_0x1ef3fb&&(_0x38d10f['parentExecutionId']=_0x1ef3fb),_0x38d10f;}let _0x2e1bd7=null,_0x20ce9b=null,_0x320cf3=null,_0x44c39d=null!==(_0x38fda5=null==_0x479d77?void 0x0:_0x479d77['checkpointId'])&&void 0x0!==_0x38fda5?_0x38fda5:null,_0x5e210d=null!==(_0x4a7fd7=null==_0x479d77?void 0x0:_0x479d77['checkpointId'])&&void 0x0!==_0x4a7fd7?_0x4a7fd7:null;const _0xee5e15=Date['now'](),_0x3c3cad=resolveExecutionInput({'input':_0x20eff3,'isContinuing':_0x896e0f,'source':_0x479d77})['input'];if(this['workflow']['observability']){_0x2e1bd7=createWorkflowObservability({'appId':this['notifier']['appId'],'token':null!==(_0x1187b6=this['notifier']['authToken'])&&void 0x0!==_0x1187b6?_0x1187b6:null}),await _0x2e1bd7['registerWorkflow'](this['workflow']);const _0x4c72bf=await _0x2e1bd7['startExecution']({'workflowId':this['workflow']['name'],'userId':this['senderId'],'sessionId':_0x3c98ec,'mode':_0x44b206,'parentExecutionId':_0x1ef3fb,'fromCheckpointId':_0x4391e0,'input':_0x3c3cad,'startedAtMs':_0xee5e15,'startedAt':new Date(_0xee5e15)['toISOString']()});_0x20ce9b=_0x4c72bf['executionId'],_0x320cf3=_0x4c72bf['startedAt'];}_0x20ce9b||(_0x20ce9b=shortId('exec'));const _0x45a491=async _0x23981c=>{var _0x350dde,_0x38a797,_0x3c5fb0,_0x137afe,_0x3b60f8;if(!_0x2586db||!_0x3c98ec)return;const _0x3d32bf=this['workflow']['name'],_0x25a5e6='completed'===_0x23981c['phase']||'ok'===_0x23981c['status']||'completed'===_0x23981c['status']?'completed':'error'===_0x23981c['phase']||'error'===_0x23981c['status']?'error':'running',_0x44c790=null!==(_0x350dde=_0x23981c['sessionStatus'])&&void 0x0!==_0x350dde?_0x350dde:'completed'===_0x25a5e6?'completed':'error'===_0x25a5e6?'error':'running',_0x133d43=await safeCheckpointPut(_0x2586db,{'sessionId':_0x3c98ec,'executionId':_0x20ce9b,'appId':this['notifier']['appId'],'userId':this['senderId'],'kind':'workflow','name':_0x3d32bf,'workflowId':_0x3d32bf,'sessionName':_0x3d32bf,'parentCheckpointId':_0x5e210d,'status':_0x25a5e6,'sessionStatus':_0x44c790,'mode':_0x44b206,'parentExecutionId':_0x1ef3fb,'fromCheckpointId':_0x4391e0,'state':{'cursor':{'phase':_0x23981c['phase'],'round':0x0,'node':this['workflow']['name']},'input':null!==(_0x3c5fb0=null!=_0x20eff3?_0x20eff3:null===(_0x38a797=null==_0x479d77?void 0x0:_0x479d77['state'])||void 0x0===_0x38a797?void 0x0:_0x38a797['input'])&&void 0x0!==_0x3c5fb0?_0x3c5fb0:null,'messages':[],'workflowState':_0x3a733e,'pendingToolCalls':[],'lastError':null!==(_0x137afe=_0x23981c['lastError'])&&void 0x0!==_0x137afe?_0x137afe:null,'result':null!==(_0x3b60f8=_0x23981c['result'])&&void 0x0!==_0x3b60f8?_0x3b60f8:null,'meta':{}}});(null==_0x133d43?void 0x0:_0x133d43['checkpointId'])&&(_0x44c39d=_0x133d43['checkpointId'],_0x5e210d=_0x133d43['checkpointId']),'completed'!==_0x25a5e6&&'error'!==_0x25a5e6||await finalizeExecutionCheckpoints(_0x2586db,{'sessionId':_0x3c98ec,'executionId':_0x20ce9b,'status':_0x25a5e6,'sessionStatus':_0x44c790});};let _0x290b5e=null;if(_0x2e1bd7&&_0x20ce9b){const _0x3a1111=await _0x2e1bd7['recordStep'](_0x20ce9b,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':this['workflow']['name'],'status':'ok','latencyMs':0x0,'parentStepId':null,'input':snapshot(_0x20eff3),'state':snapshot(_0x3a733e)});_0x290b5e=null!==(_0x793a2d=null==_0x3a1111?void 0x0:_0x3a1111['id'])&&void 0x0!==_0x793a2d?_0x793a2d:null;}await _0x45a491({'phase':'start'});const _0x4ee9b0=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x20eff3,'state':_0x3a733e,'observability':_0x2e1bd7,'executionId':_0x20ce9b,'entryStepId':_0x290b5e,'sessionId':_0x3c98ec,'checkpointer':_0x2586db});let _0x42e88c;_0x4ee9b0['_runMode']=_0x44b206,_0x4ee9b0['_resume']=null==_0x411845?void 0x0:_0x411845['resume'],_0x4ee9b0['_fromCheckpointId']=_0x4391e0,_0x4ee9b0['_parentExecutionId']=_0x1ef3fb;let _0x50ccb8='ok',_0x1d9de5=null;try{_0x42e88c=await withWorkflowMiddleware(this['workflow'],_0x4ee9b0,()=>this['workflow']['entry'](_0x4ee9b0)),await _0x45a491({'phase':'completed','status':'ok','result':_0x42e88c});}catch(_0x22f172){throw _0x50ccb8='error',_0x1d9de5={'message':null!==(_0x261502=null==_0x22f172?void 0x0:_0x22f172['message'])&&void 0x0!==_0x261502?_0x261502:String(_0x22f172),'stack':null==_0x22f172?void 0x0:_0x22f172['stack']},await _0x45a491({'phase':'error','status':'error','lastError':_0x1d9de5}),_0x22f172;}finally{if(_0x2e1bd7&&_0x20ce9b){await _0x2e1bd7['recordStep'](_0x20ce9b,{'type':STEP_TYPE_END,'kind':'end','label':this['workflow']['name'],'status':_0x50ccb8,'latencyMs':0x0,'parentStepId':_0x4ee9b0['getEndParentStepId'](),'output':snapshot('ok'===_0x50ccb8?_0x42e88c:null),'state':snapshot(_0x4ee9b0['state']),'error':_0x1d9de5});const _0x2e6270=Date['now'](),_0x540713=new Date(_0x2e6270)['toISOString'](),_0x2bcdc3=_0x2e1bd7['getStepCount']();await _0x2e1bd7['completeExecution']({'executionId':_0x20ce9b,'status':'ok'===_0x50ccb8?'completed':_0x50ccb8,'endedAt':_0x540713,'durationMs':_0x2e6270-_0xee5e15,'stepCount':_0x2bcdc3,'error':_0x1d9de5,'result':'ok'===_0x50ccb8?_0x42e88c:null,'startedAt':_0x320cf3});}}const _0x5d8a7b={'result':_0x42e88c,'state':_0x3a733e,'mode':_0x44b206};return _0x20ce9b&&(_0x5d8a7b['executionId']=_0x20ce9b),_0x3c98ec&&(_0x5d8a7b['sessionId']=_0x3c98ec),_0x44c39d&&(_0x5d8a7b['checkpointId']=_0x44c39d),_0x1ef3fb&&(_0x5d8a7b['parentExecutionId']=_0x1ef3fb),_0x5d8a7b;}}
@@ -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(_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
+ 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(_0x22b2f9){if(null==_0x22b2f9||''===String(_0x22b2f9)['trim']())return'Custom';const _0x8737cb=String(_0x22b2f9);if(LOG_TYPE_BY_API[_0x8737cb])return LOG_TYPE_BY_API[_0x8737cb];const _0x2eb451=_0x8737cb['toLowerCase']();for(const [_0x27f491,_0x36aac5]of Object['entries'](LOG_TYPE_BY_API))if(_0x27f491['toLowerCase']()===_0x2eb451)return _0x36aac5;return _0x8737cb;}export function resolveApiName(_0x3b491c){const _0x2c7c0b=null==_0x3b491c?void 0x0:_0x3b491c['kind'];if(null==_0x2c7c0b||''===String(_0x2c7c0b)['trim']())return null;const _0x2a151c=String(_0x2c7c0b);return LEGACY_KIND_TO_API[_0x2a151c]?LEGACY_KIND_TO_API[_0x2a151c]:'agent'===_0x2a151c||SDK_API_STEP_TYPES['includes'](_0x2a151c)||'semanticSearch'===_0x2a151c?_0x2a151c:null;}export function resolveStepType(_0x56e3a5){if(null!=(null==_0x56e3a5?void 0x0:_0x56e3a5['type'])&&''!==String(_0x56e3a5['type'])['trim']()){const _0x224c7e=String(_0x56e3a5['type'])['trim']();return STRUCTURAL_STEP_TYPES['includes'](_0x224c7e)||Object['values'](LOG_TYPE_BY_API)['includes'](_0x224c7e)?_0x224c7e:toLogStepType(_0x224c7e);}const _0x2fcb41=resolveApiName(_0x56e3a5);return _0x2fcb41?toLogStepType(_0x2fcb41):'Custom';}
@@ -1 +1 @@
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
+ 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{resolveRunSession,normalizeRunMode,loadSourceCheckpoint,resolveExecutionInput}from'../checkpoint/index.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';import{STEP_TYPE_END,STEP_TYPE_ENTRY}from'./stepTypes.js';function normalizeDescription(_0x240097){if(null==_0x240097||''===_0x240097)return;if('string'!=typeof _0x240097)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20a\x20string');const _0x3a2738=_0x240097['trim']();if(_0x3a2738['length']>0x64)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20at\x20most\x20100\x20characters');return _0x3a2738['length']>0x0?_0x3a2738:void 0x0;}export class Workflow{constructor({name:_0x13146b,description:_0x5a5e79,observability:_0x251865=!0x1,capabilities:_0x263fc6,middleware:_0x8f48d0,entry:_0x4dc509}){if(!_0x13146b||'string'!=typeof _0x13146b)throw new WorkflowError('Workflow\x20name\x20is\x20required');if('function'!=typeof _0x4dc509)throw new WorkflowError('Workflow\x20entry\x20must\x20be\x20a\x20function');this['name']=_0x13146b['trim'](),this['description']=normalizeDescription(_0x5a5e79),this['observability']=Boolean(_0x251865),this['capabilities']=normalizeCapabilities(_0x263fc6),this['middleware']=normalizeMiddleware(_0x8f48d0,this['name'],'Workflow'),this['entry']=_0x4dc509,this['_agents']=new Map(),this['_registeredWithObservability']=!0x1,this['_listenNotifier']=null,this['_backendRegistrations']=new WeakMap();}['_syncBackendRegistration'](_0x4c3b3e){var _0x1ede10,_0x556a16,_0x1c18ab;const _0x2b6cf1=null===(_0x1ede10=null==_0x4c3b3e?void 0x0:_0x4c3b3e['_agentServices'])||void 0x0===_0x1ede10?void 0x0:_0x1ede10['sync'];if(!_0x2b6cf1||'function'!=typeof _0x2b6cf1['enqueueWorkflow'])return;for(const _0x35c22a of this['_agents']['values']())_0x35c22a instanceof Agent&&_0x2b6cf1['enqueueAgent'](_0x35c22a);const _0x25028e={'workflowId':this['name'],'name':this['name'],'description':null!==(_0x556a16=this['description'])&&void 0x0!==_0x556a16?_0x556a16:'','agentIds':[...this['_agents']]['map'](([_0x3cac74,_0x131e4d])=>agentBackendId(_0x131e4d instanceof Agent?_0x131e4d['name']:_0x3cac74)),'hostUserId':null!==(_0x1c18ab=_0x4c3b3e['userId'])&&void 0x0!==_0x1c18ab?_0x1c18ab:null,'capabilities':this['capabilities']},_0x15e7c2=JSON['stringify'](_0x25028e);this['_backendRegistrations']['get'](_0x4c3b3e)!==_0x15e7c2&&(this['_backendRegistrations']['set'](_0x4c3b3e,_0x15e7c2),_0x2b6cf1['enqueueWorkflow'](_0x25028e));}['registerAgent'](_0x1b7e17,_0x1e98e0){if(!_0x1b7e17||'string'!=typeof _0x1b7e17)throw new WorkflowError('Agent\x20registration\x20name\x20is\x20required');if(isRemoteAgentRef(_0x1e98e0))this['_agents']['set'](_0x1b7e17,{'receiverId':_0x1e98e0['receiverId']['trim']()});else{if(!_0x1e98e0||'function'!=typeof _0x1e98e0['run'])throw new WorkflowError('Invalid\x20agent\x20for\x20\x22'+_0x1b7e17+'\x22\x20(expected\x20Agent\x20or\x20{\x20receiverId\x20})');this['_agents']['set'](_0x1b7e17,_0x1e98e0);}return this['_listenNotifier']&&this['_syncBackendRegistration'](this['_listenNotifier']),this;}['registerAgents'](_0x231bd6){for(const [_0x503b9c,_0x53fa20]of Object['entries'](_0x231bd6))this['registerAgent'](_0x503b9c,_0x53fa20);return this;}['getAgent'](_0x4f5b51){const _0xbf39c0=this['_agents']['get'](_0x4f5b51);if(_0xbf39c0&&!isRemoteAgentRef(_0xbf39c0))return _0xbf39c0;}['getAgentRegistration'](_0x301d8c){return this['_agents']['get'](_0x301d8c);}['hasLocalAgent'](_0x41431a){return Boolean(this['getAgent'](_0x41431a));}['listen'](_0x43c612){if(!_0x43c612)throw new WorkflowError('workflow.listen\x20requires\x20a\x20DNotifier\x20instance');return this['_listenNotifier']&&this['_listenNotifier']!==_0x43c612&&this['_listenNotifier']['_unregisterWorkflowListener'](this),this['_listenNotifier']=_0x43c612,_0x43c612['_registerWorkflowListener'](this),this['_syncBackendRegistration'](_0x43c612),this;}['stopListening'](){var _0x5b04c8;return null===(_0x5b04c8=this['_listenNotifier'])||void 0x0===_0x5b04c8||_0x5b04c8['_unregisterWorkflowListener'](this),this['_listenNotifier']=null,this;}async['_handleRemoteInvoke'](_0x43497c,_0x38b16f,_0x57f7f2){var _0x3a1c3e,_0x40ab68,_0xb77f4a,_0x5c45ff,_0x577721,_0x1136e7,_0x3e1088,_0x1e6d9c,_0x490692,_0x2fdddd,_0x405ccc,_0x21f956,_0x5e515c,_0x53efd9,_0x485b88,_0x2d59df,_0xcd8767,_0x5f0cf0,_0x468a73,_0x451b28,_0x167d63,_0x38e185;const _0x536906=_0x57f7f2['agentName'],_0x1569a8=_0x57f7f2['correlationId'],_0x38e4e6='string'==typeof _0x57f7f2['replyTo']&&_0x57f7f2['replyTo']['trim']()||bareUserId(_0x43497c['appId'],null===(_0x3a1c3e=null==_0x38b16f?void 0x0:_0x38b16f['metadata'])||void 0x0===_0x3a1c3e?void 0x0:_0x3a1c3e['sender']);if(!_0x1569a8||!_0x38e4e6)return;if(!this['hasLocalAgent'](_0x536906))return void await sendRemoteAgentError(_0x43497c,{'senderId':_0x43497c['userId'],'receiverId':_0x38e4e6,'correlationId':_0x1569a8,'agentName':_0x536906,'message':'Agent\x20not\x20hosted:\x20'+_0x536906});const _0x257a8c=_0x57f7f2['state']&&'object'==typeof _0x57f7f2['state']&&!Array['isArray'](_0x57f7f2['state'])?{..._0x57f7f2['state']}:{},{mode:_0x262163,fromCheckpointId:_0x42b61e,isContinuing:_0x4dee6e}=normalizeRunMode({'mode':_0x57f7f2['mode'],'resume':_0x57f7f2['resume'],'fromCheckpointId':_0x57f7f2['fromCheckpointId']});if(_0x4dee6e&&!_0x57f7f2['sessionId']&&!_0x42b61e)return void await sendRemoteAgentError(_0x43497c,{'senderId':_0x43497c['userId'],'receiverId':_0x38e4e6,'correlationId':_0x1569a8,'agentName':_0x536906,'message':'resume/retry/replay\x20requires\x20sessionId\x20or\x20fromCheckpointId'});const _0x4c7645=this['getAgent'](_0x536906),_0x57998c=Boolean(this['observability']||(null==_0x4c7645?void 0x0:_0x4c7645['observability'])),_0x3d5f73=void 0x0!==_0x57f7f2['checkpointer']?_0x57f7f2['checkpointer']:_0x4dee6e&&!_0x57f7f2['sessionId']?'remote':void 0x0;let {checkpointer:_0x500709,sessionId:_0x31699b}=resolveRunSession(_0x43497c,{'sessionId':null!==(_0x40ab68=_0x57f7f2['sessionId'])&&void 0x0!==_0x40ab68?_0x40ab68:null,'checkpointer':_0x3d5f73,'needTraceSession':_0x57998c}),_0xece63e=null,_0x26f6a9=_0x42b61e,_0x248a29=_0x257a8c,_0x1acc13=null;if(_0x4dee6e&&_0x500709){if(_0x1acc13=await loadSourceCheckpoint(_0x500709,{'sessionId':_0x31699b,'fromCheckpointId':_0x42b61e}),!_0x1acc13)return void await sendRemoteAgentError(_0x43497c,{'senderId':_0x43497c['userId'],'receiverId':_0x38e4e6,'correlationId':_0x1569a8,'agentName':_0x536906,'message':_0x42b61e?'Checkpoint\x20not\x20found:\x20'+_0x42b61e:'No\x20checkpoint\x20found\x20to\x20resume/retry/replay'});!_0x31699b&&_0x1acc13['sessionId']&&(_0x31699b=_0x1acc13['sessionId']),_0xece63e=null!==(_0xb77f4a=_0x1acc13['executionId'])&&void 0x0!==_0xb77f4a?_0xb77f4a:null,_0x26f6a9=null!==(_0x5c45ff=null!=_0x42b61e?_0x42b61e:_0x1acc13['checkpointId'])&&void 0x0!==_0x5c45ff?_0x5c45ff:null,_0x248a29={...(null===(_0x577721=_0x1acc13['state'])||void 0x0===_0x577721?void 0x0:_0x577721['workflowState'])&&'object'==typeof _0x1acc13['state']['workflowState']&&!Array['isArray'](_0x1acc13['state']['workflowState'])?{..._0x1acc13['state']['workflowState']}:{},..._0x257a8c};}else{if(_0x500709&&_0x31699b&&0x0===Object['keys'](_0x257a8c)['length']){const _0x30c851=await loadSourceCheckpoint(_0x500709,{'sessionId':_0x31699b}),_0xe540e=(null===(_0x1136e7=null==_0x30c851?void 0x0:_0x30c851['state'])||void 0x0===_0x1136e7?void 0x0:_0x1136e7['workflowState'])&&'object'==typeof _0x30c851['state']['workflowState']&&!Array['isArray'](_0x30c851['state']['workflowState'])?{..._0x30c851['state']['workflowState']}:{};Object['keys'](_0xe540e)['length']>0x0&&(_0x248a29=_0xe540e);}}const _0x4ca5d7=resolveExecutionInput({'input':_0x57f7f2['input'],'isContinuing':_0x4dee6e,'source':_0x1acc13})['input'];let _0x407577=null,_0x23a6ed=null!=(null===(_0x3e1088=_0x57f7f2['trace'])||void 0x0===_0x3e1088?void 0x0:_0x3e1088['executionId'])&&''!==String(_0x57f7f2['trace']['executionId'])['trim']()?String(_0x57f7f2['trace']['executionId']):null,_0x159071=!0x1,_0x27fba0=null;const _0x16fae0=Date['now'](),_0x19e4d6=_0x4c7645?agentBackendId(_0x4c7645['name']):this['name'];_0x57998c&&(_0x23a6ed?_0x407577=createWorkflowObservability({'appId':_0x43497c['appId'],'token':null!==(_0x1e6d9c=_0x43497c['authToken'])&&void 0x0!==_0x1e6d9c?_0x1e6d9c:null,'appendOnly':!0x0}):(_0x407577=createWorkflowObservability({'appId':_0x43497c['appId'],'token':null!==(_0x490692=_0x43497c['authToken'])&&void 0x0!==_0x490692?_0x490692:null}),_0x159071=!0x0),await _0x407577['registerWorkflow']({'name':_0x19e4d6,'description':(null==_0x4c7645?void 0x0:_0x4c7645['description'])||this['description']||void 0x0,'observability':!0x0}),_0x159071&&(_0x27fba0=await _0x407577['startExecution']({'workflowId':_0x19e4d6,'userId':_0x43497c['userId'],'sessionId':_0x31699b,'mode':_0x262163,'parentExecutionId':_0xece63e,'fromCheckpointId':_0x26f6a9,'input':_0x4ca5d7,'startedAtMs':_0x16fae0,'startedAt':new Date(_0x16fae0)['toISOString']()}),_0x23a6ed=_0x27fba0['executionId']));const _0x335c4b=new WorkflowContext({'notifier':_0x43497c,'senderId':_0x43497c['userId'],'workflow':this,'input':null!==(_0x2fdddd=_0x57f7f2['input'])&&void 0x0!==_0x2fdddd?_0x2fdddd:null,'state':_0x248a29,'observability':_0x407577,'executionId':_0x23a6ed,'traceParentStepId':null!==(_0x21f956=null===(_0x405ccc=_0x57f7f2['trace'])||void 0x0===_0x405ccc?void 0x0:_0x405ccc['parentStepId'])&&void 0x0!==_0x21f956?_0x21f956:null,'sessionId':_0x31699b,'checkpointer':_0x500709});_0x335c4b['_runMode']=_0x262163,_0x335c4b['_resume']=!0x0===_0x57f7f2['resume']||void 0x0,_0x335c4b['_fromCheckpointId']=_0x26f6a9,_0x335c4b['_parentExecutionId']=_0xece63e;let _0x3c493a='ok',_0x4655db=null,_0x30d452=null,_0x2e4406=null;try{if(_0x159071&&_0x407577&&_0x23a6ed){const _0x158548=await _0x407577['recordStep'](_0x23a6ed,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':_0x536906,'status':'ok','latencyMs':0x0,'parentStepId':null,'input':_0x4ca5d7});_0x335c4b['_entryStepId']=null!==(_0x5e515c=null==_0x158548?void 0x0:_0x158548['id'])&&void 0x0!==_0x5e515c?_0x5e515c:null,_0x335c4b['_chainHeadStepId']=null!==(_0x53efd9=null==_0x158548?void 0x0:_0x158548['id'])&&void 0x0!==_0x53efd9?_0x53efd9:null;}if(_0x30d452=await _0x335c4b['runAgent'](_0x536906,{'input':void 0x0!==_0x57f7f2['input']?_0x57f7f2['input']:_0x335c4b['input']}),_0x2e4406=_0x30d452&&'object'==typeof _0x30d452&&!Array['isArray'](_0x30d452)?_0x30d452:null,_0x407577&&_0x23a6ed){if(_0x159071){const _0x6804a8=_0x2e4406&&'string'==typeof _0x2e4406['lastStepId']&&''!==_0x2e4406['lastStepId']['trim']()&&_0x2e4406['lastStepId']||(null===(_0x485b88=_0x335c4b['getEndParentStepId'])||void 0x0===_0x485b88?void 0x0:_0x485b88['call'](_0x335c4b))||_0x335c4b['_entryStepId']||null;await _0x407577['recordStep'](_0x23a6ed,{'type':STEP_TYPE_END,'kind':'end','label':_0x536906,'status':_0x3c493a,'latencyMs':0x0,'parentStepId':_0x6804a8,'output':'ok'===_0x3c493a?_0x30d452:null});const _0x4893ff=Date['now']();await _0x407577['completeExecution']({'executionId':_0x23a6ed,'status':'completed','endedAt':new Date(_0x4893ff)['toISOString'](),'durationMs':_0x4893ff-_0x16fae0,'stepCount':_0x407577['getStepCount'](),'result':_0x30d452,'startedAt':null==_0x27fba0?void 0x0:_0x27fba0['startedAt'],'sessionId':_0x31699b});}else await _0x407577['completeExecution']({'executionId':_0x23a6ed,'stepCount':_0x407577['getStepCount']()});}await sendRemoteAgentResult(_0x43497c,{'senderId':_0x43497c['userId'],'receiverId':_0x38e4e6,'correlationId':_0x1569a8,'agentName':_0x536906,'output':_0x30d452,'state':_0x335c4b['state'],'sessionId':null!==(_0x2d59df=null==_0x2e4406?void 0x0:_0x2e4406['sessionId'])&&void 0x0!==_0x2d59df?_0x2d59df:_0x31699b,'checkpointId':null!==(_0xcd8767=null==_0x2e4406?void 0x0:_0x2e4406['checkpointId'])&&void 0x0!==_0xcd8767?_0xcd8767:null,'executionId':null!==(_0x5f0cf0=null==_0x2e4406?void 0x0:_0x2e4406['executionId'])&&void 0x0!==_0x5f0cf0?_0x5f0cf0:_0x23a6ed,'mode':null!==(_0x468a73=null==_0x2e4406?void 0x0:_0x2e4406['mode'])&&void 0x0!==_0x468a73?_0x468a73:_0x262163});}catch(_0x3eeb8f){if(_0x3c493a='error',_0x4655db={'message':null!==(_0x451b28=null==_0x3eeb8f?void 0x0:_0x3eeb8f['message'])&&void 0x0!==_0x451b28?_0x451b28:String(_0x3eeb8f),'stack':null==_0x3eeb8f?void 0x0:_0x3eeb8f['stack']},_0x407577&&_0x23a6ed)try{if(_0x159071){await _0x407577['recordStep'](_0x23a6ed,{'type':STEP_TYPE_END,'kind':'end','label':_0x536906,'status':_0x3c493a,'latencyMs':0x0,'parentStepId':null!==(_0x167d63=_0x335c4b['_entryStepId'])&&void 0x0!==_0x167d63?_0x167d63:null,'error':_0x4655db});const _0x4760f0=Date['now']();await _0x407577['completeExecution']({'executionId':_0x23a6ed,'status':'error','endedAt':new Date(_0x4760f0)['toISOString'](),'durationMs':_0x4760f0-_0x16fae0,'stepCount':_0x407577['getStepCount'](),'error':_0x4655db,'startedAt':null==_0x27fba0?void 0x0:_0x27fba0['startedAt'],'sessionId':_0x31699b});}else await _0x407577['completeExecution']({'executionId':_0x23a6ed,'stepCount':_0x407577['getStepCount']()});}catch{}await sendRemoteAgentError(_0x43497c,{'senderId':_0x43497c['userId'],'receiverId':_0x38e4e6,'correlationId':_0x1569a8,'agentName':_0x536906,'message':null!==(_0x38e185=null==_0x3eeb8f?void 0x0:_0x3eeb8f['message'])&&void 0x0!==_0x38e185?_0x38e185:String(_0x3eeb8f)});}}}
@@ -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:_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};}}
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:_0x37e4c9=null,token:_0x5b98bd=null,requestTimeoutMs:_0x5c09ab=0x1388}={}){this['appId']=_0x37e4c9,this['token']=_0x5b98bd,this['requestTimeoutMs']=_0x5c09ab;}['configure']({appId:_0x12f23a,token:_0x1a658b,requestTimeoutMs:_0x1c5402}={}){void 0x0!==_0x12f23a&&(this['appId']=_0x12f23a),void 0x0!==_0x1a658b&&(this['token']=_0x1a658b),void 0x0!==_0x1c5402&&(this['requestTimeoutMs']=_0x1c5402);}['_transport'](_0x44a0e6){const _0x342455=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x44a0e6,'headers':_0x342455,'timeoutMs':this['requestTimeoutMs']});}async['_post'](_0x3162cd,_0x3415ac){if(this['token'])try{await this['_transport'](_0x3162cd)['send'](_0x3415ac);}catch{}}async['registerWorkflow'](_0x1caa6e){const _0x3f4d02={'appId':_0x1caa6e['appId'],'workflowId':_0x1caa6e['workflowId'],'name':_0x1caa6e['name']};return null!=_0x1caa6e['description']&&''!==_0x1caa6e['description']&&(_0x3f4d02['description']=_0x1caa6e['description']),await this['_post'](DNotifierEndpoints['workflowRegisterUrl'],_0x3f4d02),{'ok':!0x0};}async['createExecution'](_0x3c1ef1){var _0x48b4d1;const _0x338bb9=null!==(_0x48b4d1=_0x3c1ef1['id'])&&void 0x0!==_0x48b4d1?_0x48b4d1:shortId('exec'),_0x5b8a97={'id':_0x338bb9,'appId':_0x3c1ef1['appId'],'workflowId':_0x3c1ef1['workflowId'],'userId':_0x3c1ef1['userId'],'status':'in_progress','stepCount':0x0,'startedAt':_0x3c1ef1['startedAt']};return null!=_0x3c1ef1['sessionId']&&''!==_0x3c1ef1['sessionId']&&(_0x5b8a97['sessionId']=_0x3c1ef1['sessionId']),null!=_0x3c1ef1['mode']&&''!==_0x3c1ef1['mode']&&(_0x5b8a97['mode']=_0x3c1ef1['mode']),null!=_0x3c1ef1['parentExecutionId']&&''!==_0x3c1ef1['parentExecutionId']&&(_0x5b8a97['parentExecutionId']=_0x3c1ef1['parentExecutionId']),null!=_0x3c1ef1['fromCheckpointId']&&''!==_0x3c1ef1['fromCheckpointId']&&(_0x5b8a97['fromCheckpointId']=_0x3c1ef1['fromCheckpointId']),setJsonColumn(_0x5b8a97,'input',_0x3c1ef1['input']),await this['_post'](DNotifierEndpoints['workflowExecutionsUrl'],_0x5b8a97),{'executionId':_0x338bb9,'record':_0x5b8a97};}async['updateExecution'](_0x24aafd,_0x236034){const _0x7270ba={'id':_0x24aafd,'status':_0x236034['status'],'endedAt':_0x236034['endedAt'],'durationMs':_0x236034['durationMs'],'stepCount':_0x236034['stepCount']};return null!=_0x236034['sessionId']&&''!==_0x236034['sessionId']&&(_0x7270ba['sessionId']=_0x236034['sessionId']),setJsonColumn(_0x7270ba,'error',_0x236034['error']),setJsonColumn(_0x7270ba,'result',_0x236034['result']),await this['_post'](DNotifierEndpoints['workflowExecutionCompleteUrl'](_0x24aafd),_0x7270ba),{'ok':!0x0,'record':_0x7270ba};}async['addStep'](_0x3cbc8c,_0x1b5ec3){var _0x50676a,_0x44da41,_0x4a1c70,_0x23ba6c,_0x31b255,_0x208b75;const _0x391908=resolveStepType(_0x1b5ec3),_0x122ce6=null!==(_0x4a1c70=null!==(_0x44da41=null!==(_0x50676a=_0x1b5ec3['agentName'])&&void 0x0!==_0x50676a?_0x50676a:_0x1b5ec3['kind'])&&void 0x0!==_0x44da41?_0x44da41:_0x1b5ec3['apiName'])&&void 0x0!==_0x4a1c70?_0x4a1c70:null,_0x38e142={'id':_0x1b5ec3['id'],'executionId':_0x3cbc8c,'kind':_0x122ce6,'label':_0x1b5ec3['label'],'type':_0x391908,'step_type':_0x391908,'status':_0x1b5ec3['status'],'executedAt':_0x1b5ec3['executedAt'],'latencyMs':null!==(_0x23ba6c=_0x1b5ec3['latencyMs'])&&void 0x0!==_0x23ba6c?_0x23ba6c:0x0,'tokensIn':null!==(_0x31b255=_0x1b5ec3['tokensIn'])&&void 0x0!==_0x31b255?_0x31b255:0x0,'tokensOut':null!==(_0x208b75=_0x1b5ec3['tokensOut'])&&void 0x0!==_0x208b75?_0x208b75:0x0};return null!=_0x1b5ec3['sessionId']&&''!==_0x1b5ec3['sessionId']&&(_0x38e142['sessionId']=_0x1b5ec3['sessionId']),null!=_0x1b5ec3['apiName']&&''!==_0x1b5ec3['apiName']&&(_0x38e142['apiName']=_0x1b5ec3['apiName']),null!=_0x1b5ec3['agentName']&&''!==_0x1b5ec3['agentName']&&(_0x38e142['agentName']=_0x1b5ec3['agentName']),null!=_0x1b5ec3['model']&&''!==_0x1b5ec3['model']&&(_0x38e142['model']='string'==typeof _0x1b5ec3['model']?_0x1b5ec3['model']:String(_0x1b5ec3['model'])),null!=_0x1b5ec3['provider']&&''!==_0x1b5ec3['provider']&&(_0x38e142['provider']='string'==typeof _0x1b5ec3['provider']?_0x1b5ec3['provider']:String(_0x1b5ec3['provider'])),setJsonColumn(_0x38e142,'input',_0x1b5ec3['input']),setJsonColumn(_0x38e142,'output',_0x1b5ec3['output']),setJsonColumn(_0x38e142,'state',_0x1b5ec3['state']),setJsonColumn(_0x38e142,'error',_0x1b5ec3['error']),null!=_0x1b5ec3['parentStepId']&&''!==_0x1b5ec3['parentStepId']&&(_0x38e142['parentStepId']=_0x1b5ec3['parentStepId']),null!=_0x1b5ec3['siblingIndex']&&''!==_0x1b5ec3['siblingIndex']&&(_0x38e142['siblingIndex']=_0x1b5ec3['siblingIndex']),null!=_0x1b5ec3['branchKey']&&''!==_0x1b5ec3['branchKey']&&(_0x38e142['branchKey']=_0x1b5ec3['branchKey']),await this['_post'](DNotifierEndpoints['workflowExecutionStepsUrl'](_0x3cbc8c),_0x38e142),{'ok':!0x0};}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnotifier-realtime/dnotifier",
3
- "version": "1.1.31",
3
+ "version": "1.1.34",
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",