@dnotifier-realtime/dnotifier 1.1.18 → 1.1.20

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 (46) hide show
  1. package/dist/cjs/dnotifier.js +1 -1
  2. package/dist/cjs/providers/openai.js +1 -1
  3. package/dist/cjs/transport/httpTransport.js +1 -1
  4. package/dist/cjs/transport/websocketTransport.js +1 -1
  5. package/dist/cjs/utils/buffer.js +1 -1
  6. package/dist/cjs/utils/frame.js +1 -1
  7. package/dist/cjs/utils/id.js +1 -1
  8. package/dist/cjs/utils/payload.js +1 -1
  9. package/dist/config/endpoints.js +1 -1
  10. package/dist/dnotifier.cjs +495 -75
  11. package/dist/dnotifier.d.ts +28 -0
  12. package/dist/dnotifier.d.ts.map +1 -1
  13. package/dist/dnotifier.js +1 -1
  14. package/dist/providers/openai.js +1 -1
  15. package/dist/transport/httpTransport.js +1 -1
  16. package/dist/transport/websocketTransport.js +1 -1
  17. package/dist/utils/buffer.js +1 -1
  18. package/dist/utils/frame.js +1 -1
  19. package/dist/utils/id.js +1 -1
  20. package/dist/utils/logs.js +1 -1
  21. package/dist/utils/payload.js +1 -1
  22. package/dist/workflow/agent.js +1 -1
  23. package/dist/workflow/context.d.ts +8 -0
  24. package/dist/workflow/context.d.ts.map +1 -1
  25. package/dist/workflow/context.js +1 -1
  26. package/dist/workflow/errors.js +1 -1
  27. package/dist/workflow/graphParents.js +1 -1
  28. package/dist/workflow/ids.js +1 -1
  29. package/dist/workflow/index.d.ts +1 -0
  30. package/dist/workflow/index.js +1 -1
  31. package/dist/workflow/jsonPayload.js +1 -1
  32. package/dist/workflow/mockObservabilityClient.js +1 -1
  33. package/dist/workflow/observability.js +1 -1
  34. package/dist/workflow/remoteAgentClient.d.ts +30 -0
  35. package/dist/workflow/remoteAgentClient.d.ts.map +1 -0
  36. package/dist/workflow/remoteAgentClient.js +1 -0
  37. package/dist/workflow/remoteAgentProtocol.d.ts +50 -0
  38. package/dist/workflow/remoteAgentProtocol.d.ts.map +1 -0
  39. package/dist/workflow/remoteAgentProtocol.js +1 -0
  40. package/dist/workflow/runner.js +1 -1
  41. package/dist/workflow/stepTypes.js +1 -1
  42. package/dist/workflow/workflow.d.ts +15 -3
  43. package/dist/workflow/workflow.d.ts.map +1 -1
  44. package/dist/workflow/workflow.js +1 -1
  45. package/dist/workflow/workflowObservabilityClient.js +1 -1
  46. package/package.json +2 -1
@@ -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:_0x1ddf72,token:_0x3eb1b1=null,client:_0x1ee0e2,appendOnly:_0x2038c1=!0x1}){this['appId']=_0x1ddf72,this['token']=_0x3eb1b1,this['client']=null!=_0x1ee0e2?_0x1ee0e2:new WorkflowObservabilityClient({'appId':_0x1ddf72,'token':_0x3eb1b1}),this['client']['configure']({'appId':_0x1ddf72,'token':_0x3eb1b1}),this['_registeredWorkflowNames']=new Set(),this['_stepCounter']=0x0,this['_appendOnly']=Boolean(_0x2038c1);}['allocateStepId'](){return shortId('step');}async['registerWorkflow'](_0x5cafce){var _0x2fb0b1;if(!this['_registeredWorkflowNames']['has'](_0x5cafce['name'])){this['_registeredWorkflowNames']['add'](_0x5cafce['name']);try{await this['client']['registerWorkflow']({'appId':this['appId'],'workflowId':_0x5cafce['name'],'name':_0x5cafce['name'],'description':null!==(_0x2fb0b1=_0x5cafce['description'])&&void 0x0!==_0x2fb0b1?_0x2fb0b1:null});}catch{}}}async['startExecution'](_0x2a8100){var _0x543b62;if(this['_appendOnly'])throw new Error('startExecution\x20is\x20not\x20allowed\x20in\x20append-only\x20workflow\x20observability\x20mode');const _0x10d93a=shortId('exec'),_0x19173a=new Date()['toISOString']();try{await this['client']['createExecution']({'id':_0x10d93a,'appId':this['appId'],'workflowId':_0x2a8100['workflowId'],'userId':_0x2a8100['userId'],'input':null!==(_0x543b62=_0x2a8100['input'])&&void 0x0!==_0x543b62?_0x543b62:null,'startedAt':_0x19173a});}catch{}return this['_stepCounter']=0x0,{'executionId':_0x10d93a,'startedAt':_0x19173a};}async['recordStep'](_0x132163,_0x2a4e1e){var _0x44a8ec,_0x603e32,_0x3614de,_0x485891,_0x55380a,_0x10fedd,_0x14ef7a,_0x5ae9b7,_0x4ce6bd;if(!_0x132163)return null;this['_stepCounter']+=0x1;const _0x4aee5e=null!==(_0x44a8ec=_0x2a4e1e['id'])&&void 0x0!==_0x44a8ec?_0x44a8ec:this['allocateStepId'](),_0x134626=resolveStepType(_0x2a4e1e),_0x32eb30=null!==(_0x485891=null!==(_0x3614de=null!==(_0x603e32=_0x2a4e1e['agentName'])&&void 0x0!==_0x603e32?_0x603e32:_0x2a4e1e['kind'])&&void 0x0!==_0x3614de?_0x3614de:_0x2a4e1e['apiName'])&&void 0x0!==_0x485891?_0x485891:null,_0x4a0185=resolveGraphParentStepId(_0x2a4e1e),_0x33572={..._0x2a4e1e,'id':_0x4aee5e,'executionId':_0x132163,'executedAt':null!==(_0x55380a=_0x2a4e1e['executedAt'])&&void 0x0!==_0x55380a?_0x55380a:new Date()['toISOString'](),'apiName':null!==(_0x10fedd=_0x2a4e1e['apiName'])&&void 0x0!==_0x10fedd?_0x10fedd:null,'agentName':null!==(_0x14ef7a=_0x2a4e1e['agentName'])&&void 0x0!==_0x14ef7a?_0x14ef7a:null,'kind':_0x32eb30,'type':_0x134626,'step_type':_0x134626,'parentStepId':_0x4a0185,'siblingIndex':null!==(_0x5ae9b7=_0x2a4e1e['siblingIndex'])&&void 0x0!==_0x5ae9b7?_0x5ae9b7:null,'branchKey':null!==(_0x4ce6bd=_0x2a4e1e['branchKey'])&&void 0x0!==_0x4ce6bd?_0x4ce6bd:null};delete _0x33572['dependsOn'],delete _0x33572['parentStepIds'];try{await this['client']['addStep'](_0x132163,_0x33572);}catch{}return _0x33572;}async['completeExecution'](_0x174582){var _0x3a6431,_0x541c87;if(!this['_appendOnly']&&_0x174582['executionId'])try{await this['client']['updateExecution'](_0x174582['executionId'],{'status':_0x174582['status'],'endedAt':_0x174582['endedAt'],'durationMs':_0x174582['durationMs'],'stepCount':_0x174582['stepCount'],'error':null!==(_0x3a6431=_0x174582['error'])&&void 0x0!==_0x3a6431?_0x3a6431:null,'result':null!==(_0x541c87=_0x174582['result'])&&void 0x0!==_0x541c87?_0x541c87:null});}catch{}}['getStepCount'](){return this['_stepCounter'];}}export function createWorkflowObservability(_0x2905f2){return new WorkflowObservability(_0x2905f2);}
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:_0x46b2e9,token:_0xb5a133=null,client:_0x1b7d83,appendOnly:_0x57cf3d=!0x1}){this['appId']=_0x46b2e9,this['token']=_0xb5a133,this['client']=null!=_0x1b7d83?_0x1b7d83:new WorkflowObservabilityClient({'appId':_0x46b2e9,'token':_0xb5a133}),this['client']['configure']({'appId':_0x46b2e9,'token':_0xb5a133}),this['_registeredWorkflowNames']=new Set(),this['_stepCounter']=0x0,this['_appendOnly']=Boolean(_0x57cf3d);}['allocateStepId'](){return shortId('step');}async['registerWorkflow'](_0x1c4cf5){var _0x2e313c;if(!this['_registeredWorkflowNames']['has'](_0x1c4cf5['name'])){this['_registeredWorkflowNames']['add'](_0x1c4cf5['name']);try{await this['client']['registerWorkflow']({'appId':this['appId'],'workflowId':_0x1c4cf5['name'],'name':_0x1c4cf5['name'],'description':null!==(_0x2e313c=_0x1c4cf5['description'])&&void 0x0!==_0x2e313c?_0x2e313c:null});}catch{}}}async['startExecution'](_0x3db69b){var _0x4f5a53;if(this['_appendOnly'])throw new Error('startExecution\x20is\x20not\x20allowed\x20in\x20append-only\x20workflow\x20observability\x20mode');const _0x59a933=shortId('exec'),_0xd930dc=new Date()['toISOString']();try{await this['client']['createExecution']({'id':_0x59a933,'appId':this['appId'],'workflowId':_0x3db69b['workflowId'],'userId':_0x3db69b['userId'],'input':null!==(_0x4f5a53=_0x3db69b['input'])&&void 0x0!==_0x4f5a53?_0x4f5a53:null,'startedAt':_0xd930dc});}catch{}return this['_stepCounter']=0x0,{'executionId':_0x59a933,'startedAt':_0xd930dc};}async['recordStep'](_0x449f5a,_0x2673d6){var _0x187975,_0x4ca562,_0x100b61,_0x14a65c,_0x5e6122,_0x521d5d,_0x5c6446,_0x2e76ba,_0x50102d;if(!_0x449f5a)return null;this['_stepCounter']+=0x1;const _0x543801=null!==(_0x187975=_0x2673d6['id'])&&void 0x0!==_0x187975?_0x187975:this['allocateStepId'](),_0x2da3f8=resolveStepType(_0x2673d6),_0x51516d=null!==(_0x14a65c=null!==(_0x100b61=null!==(_0x4ca562=_0x2673d6['agentName'])&&void 0x0!==_0x4ca562?_0x4ca562:_0x2673d6['kind'])&&void 0x0!==_0x100b61?_0x100b61:_0x2673d6['apiName'])&&void 0x0!==_0x14a65c?_0x14a65c:null,_0x58a53f=resolveGraphParentStepId(_0x2673d6),_0x1599c9={..._0x2673d6,'id':_0x543801,'executionId':_0x449f5a,'executedAt':null!==(_0x5e6122=_0x2673d6['executedAt'])&&void 0x0!==_0x5e6122?_0x5e6122:new Date()['toISOString'](),'apiName':null!==(_0x521d5d=_0x2673d6['apiName'])&&void 0x0!==_0x521d5d?_0x521d5d:null,'agentName':null!==(_0x5c6446=_0x2673d6['agentName'])&&void 0x0!==_0x5c6446?_0x5c6446:null,'kind':_0x51516d,'type':_0x2da3f8,'step_type':_0x2da3f8,'parentStepId':_0x58a53f,'siblingIndex':null!==(_0x2e76ba=_0x2673d6['siblingIndex'])&&void 0x0!==_0x2e76ba?_0x2e76ba:null,'branchKey':null!==(_0x50102d=_0x2673d6['branchKey'])&&void 0x0!==_0x50102d?_0x50102d:null};delete _0x1599c9['dependsOn'],delete _0x1599c9['parentStepIds'];try{await this['client']['addStep'](_0x449f5a,_0x1599c9);}catch{}return _0x1599c9;}async['completeExecution'](_0x13ebab){var _0x513a87,_0x239601;if(!this['_appendOnly']&&_0x13ebab['executionId'])try{await this['client']['updateExecution'](_0x13ebab['executionId'],{'status':_0x13ebab['status'],'endedAt':_0x13ebab['endedAt'],'durationMs':_0x13ebab['durationMs'],'stepCount':_0x13ebab['stepCount'],'error':null!==(_0x513a87=_0x13ebab['error'])&&void 0x0!==_0x513a87?_0x513a87:null,'result':null!==(_0x239601=_0x13ebab['result'])&&void 0x0!==_0x239601?_0x239601:null});}catch{}}['getStepCount'](){return this['_stepCounter'];}}export function createWorkflowObservability(_0xdfef16){return new WorkflowObservability(_0xdfef16);}
@@ -0,0 +1,30 @@
1
+ export function bareUserId(appId: string, prefixedSender: string): string;
2
+ export function invokeRemoteAgent(params: {
3
+ notifier: import("../dnotifier.js").DNotifier;
4
+ senderId: string;
5
+ receiverId: string;
6
+ agentName: string;
7
+ input?: any;
8
+ state?: object;
9
+ trace?: object | null;
10
+ timeoutMs?: number;
11
+ }): Promise<{
12
+ output: any;
13
+ state: object | null;
14
+ }>;
15
+ export function sendRemoteAgentResult(notifier: import("../dnotifier.js").DNotifier, params: {
16
+ senderId: string;
17
+ receiverId: string;
18
+ correlationId: string;
19
+ output?: any;
20
+ state?: object | null;
21
+ }): Promise<void>;
22
+ export function sendRemoteAgentError(notifier: import("../dnotifier.js").DNotifier, params: {
23
+ senderId: string;
24
+ receiverId: string;
25
+ correlationId: string;
26
+ message: string;
27
+ }): Promise<void>;
28
+ export function isRemoteAgentReply(data: any): boolean;
29
+ export const DEFAULT_TIMEOUT_MS: 120000;
30
+ //# sourceMappingURL=remoteAgentClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteAgentClient.d.ts","sourceRoot":"","sources":["../../src/workflow/remoteAgentClient.js"],"names":[],"mappings":"AA+BA,kCAJW,MAAM,kBACN,MAAM,GACJ,MAAM,CAWlB;AAgBD,0CAZW;IACN,QAAQ,EAAE,OAAO,iBAAiB,EAAE,SAAS,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,GAAC,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACS,OAAO,CAAC;IAAE,MAAM,EAAE,GAAC,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CA4CxD;AAYD,gDATW,OAAO,iBAAiB,EAAE,SAAS,UACnC;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,GAAC,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,iBAaH;AAWD,+CARW,OAAO,iBAAiB,EAAE,SAAS,UACnC;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,iBAYH;AAMD,yCAHW,GAAC,GACC,OAAO,CAQnB;AAlJD,iCAA2B,MAAO,CAAC"}
@@ -0,0 +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 _0x246905='undefined'!=typeof globalThis?globalThis['crypto']:void 0x0;if(_0x246905&&'function'==typeof _0x246905['randomUUID'])return _0x246905['randomUUID']();if(_0x246905&&_0x246905['getRandomValues']){const _0x2a43a3=new Uint8Array(0x10);_0x246905['getRandomValues'](_0x2a43a3),_0x2a43a3[0x6]=0xf&_0x2a43a3[0x6]|0x40,_0x2a43a3[0x8]=0x3f&_0x2a43a3[0x8]|0x80;const _0x2d70e1=[..._0x2a43a3]['map'](_0x2ae1f6=>_0x2ae1f6['toString'](0x10)['padStart'](0x2,'0'))['join']('');return _0x2d70e1['slice'](0x0,0x8)+'-'+_0x2d70e1['slice'](0x8,0xc)+'-'+_0x2d70e1['slice'](0xc,0x10)+'-'+_0x2d70e1['slice'](0x10,0x14)+'-'+_0x2d70e1['slice'](0x14);}return'corr_'+Date['now']()+'_'+Math['random']()['toString'](0x24)['slice'](0x2,0xa);}export function bareUserId(_0x45e0a7,_0x2cf7f9){if(!_0x2cf7f9||'string'!=typeof _0x2cf7f9)return'';const _0x26cdc2=_0x45e0a7+':';if(_0x2cf7f9['startsWith'](_0x26cdc2))return _0x2cf7f9['slice'](_0x26cdc2['length']);const _0x4cd41c=_0x2cf7f9['indexOf'](':');return _0x4cd41c>=0x0?_0x2cf7f9['slice'](_0x4cd41c+0x1):_0x2cf7f9;}export async function invokeRemoteAgent(_0x5ac68e){const {notifier:_0x4154b3,senderId:_0x304c75,receiverId:_0x3e5dbe,agentName:_0x51db46,input:_0x80f024,state:_0x2ed0da,trace:_0x4f4165=null,timeoutMs:_0xe1350f=DEFAULT_TIMEOUT_MS}=_0x5ac68e;if(!(null==_0x4154b3?void 0x0:_0x4154b3['isConnected']))throw new WorkflowError('Remote\x20agent\x20invoke\x20requires\x20a\x20connected\x20notifier');if(!_0x3e5dbe)throw new WorkflowError('Remote\x20agent\x20\x22'+_0x51db46+'\x22\x20is\x20missing\x20receiverId');const _0x2d2d7c=correlationId(),_0x51ce00=createInvokeEnvelope({'correlationId':_0x2d2d7c,'agentName':_0x51db46,'input':_0x80f024,'state':null!=_0x2ed0da?_0x2ed0da:null,'trace':_0x4f4165,'replyTo':_0x304c75}),_0x43c9e5=_0x4154b3['_awaitRemoteAgentReply'](_0x2d2d7c,{'timeoutMs':_0xe1350f,'agentName':_0x51db46});return await _0x4154b3['send']({'senderId':_0x304c75,'receiverId':_0x3e5dbe,'data':_0x51ce00,'saveHistory':!0x1}),_0x43c9e5;}export async function sendRemoteAgentResult(_0x30abbe,_0x6f8aef){var _0x57ef72;await _0x30abbe['send']({'senderId':_0x6f8aef['senderId'],'receiverId':_0x6f8aef['receiverId'],'data':createResultEnvelope({'correlationId':_0x6f8aef['correlationId'],'output':_0x6f8aef['output'],'state':null!==(_0x57ef72=_0x6f8aef['state'])&&void 0x0!==_0x57ef72?_0x57ef72:null}),'saveHistory':!0x1});}export async function sendRemoteAgentError(_0x46ed60,_0x2dcca8){await _0x46ed60['send']({'senderId':_0x2dcca8['senderId'],'receiverId':_0x2dcca8['receiverId'],'data':createErrorEnvelope({'correlationId':_0x2dcca8['correlationId'],'message':_0x2dcca8['message']}),'saveHistory':!0x1});}export function isRemoteAgentReply(_0x201dd1){return null!=_0x201dd1&&'object'==typeof _0x201dd1&&(_0x201dd1['op']===REMOTE_AGENT_OP['RESULT']||_0x201dd1['op']===REMOTE_AGENT_OP['ERROR']);}export{DEFAULT_TIMEOUT_MS};
@@ -0,0 +1,50 @@
1
+ export function isRemoteAgentEnvelope(data: any): boolean;
2
+ export function isRemoteAgentRef(value: any): value is {
3
+ receiverId: string;
4
+ };
5
+ export function createInvokeEnvelope(params: {
6
+ correlationId: string;
7
+ agentName: string;
8
+ input?: any;
9
+ state?: object | null;
10
+ trace?: object | null;
11
+ replyTo: string;
12
+ }): {
13
+ __dnotifier: string;
14
+ op: string;
15
+ correlationId: string;
16
+ agentName: string;
17
+ input: any;
18
+ state: object | null;
19
+ trace: object | null;
20
+ replyTo: string;
21
+ };
22
+ export function createResultEnvelope(params: {
23
+ correlationId: string;
24
+ output?: any;
25
+ state?: object | null;
26
+ }): {
27
+ __dnotifier: string;
28
+ op: string;
29
+ correlationId: string;
30
+ output: any;
31
+ state: object | null;
32
+ };
33
+ export function createErrorEnvelope(params: {
34
+ correlationId: string;
35
+ message: string;
36
+ }): {
37
+ __dnotifier: string;
38
+ op: string;
39
+ correlationId: string;
40
+ error: {
41
+ message: string;
42
+ };
43
+ };
44
+ export const REMOTE_AGENT_KIND: "dnotifier.remoteAgent";
45
+ export namespace REMOTE_AGENT_OP {
46
+ let INVOKE: string;
47
+ let RESULT: string;
48
+ let ERROR: string;
49
+ }
50
+ //# sourceMappingURL=remoteAgentProtocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteAgentProtocol.d.ts","sourceRoot":"","sources":["../../src/workflow/remoteAgentProtocol.js"],"names":[],"mappings":"AAcA,4CAHW,GAAC,GACC,OAAO,CASnB;AAMD,wCAHW,GAAC,GACC,KAAK,IAAI;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAU3C;AAYD,6CATW;IACN,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,GAAC,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;;;;;;;;;EAaH;AAKD,6CAFW;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,GAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;;;;;;EAUtE;AAKD,4CAFW;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;;;;;;EASpD;AAjFD,gCAAiC,uBAAuB,CAAC"}
@@ -0,0 +1 @@
1
+ export const REMOTE_AGENT_KIND='dnotifier.remoteAgent';export const REMOTE_AGENT_OP={'INVOKE':'invoke','RESULT':'result','ERROR':'error'};export function isRemoteAgentEnvelope(_0x506cda){return null!=_0x506cda&&'object'==typeof _0x506cda&&_0x506cda['__dnotifier']===REMOTE_AGENT_KIND&&'string'==typeof _0x506cda['op'];}export function isRemoteAgentRef(_0x5cab09){return null!=_0x5cab09&&'object'==typeof _0x5cab09&&'string'==typeof _0x5cab09['receiverId']&&''!==_0x5cab09['receiverId']['trim']()&&'function'!=typeof _0x5cab09['run'];}export function createInvokeEnvelope(_0x4aa038){var _0x4c7c9a,_0x3d8866,_0x5b0952;return{'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['INVOKE'],'correlationId':_0x4aa038['correlationId'],'agentName':_0x4aa038['agentName'],'input':null!==(_0x4c7c9a=_0x4aa038['input'])&&void 0x0!==_0x4c7c9a?_0x4c7c9a:null,'state':null!==(_0x3d8866=_0x4aa038['state'])&&void 0x0!==_0x3d8866?_0x3d8866:null,'trace':null!==(_0x5b0952=_0x4aa038['trace'])&&void 0x0!==_0x5b0952?_0x5b0952:null,'replyTo':_0x4aa038['replyTo']};}export function createResultEnvelope(_0x3ff569){var _0x27ff62,_0x24c0f1;return{'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['RESULT'],'correlationId':_0x3ff569['correlationId'],'output':null!==(_0x27ff62=_0x3ff569['output'])&&void 0x0!==_0x27ff62?_0x27ff62:null,'state':null!==(_0x24c0f1=_0x3ff569['state'])&&void 0x0!==_0x24c0f1?_0x24c0f1:null};}export function createErrorEnvelope(_0x2deaf2){return{'__dnotifier':REMOTE_AGENT_KIND,'op':REMOTE_AGENT_OP['ERROR'],'correlationId':_0x2deaf2['correlationId'],'error':{'message':_0x2deaf2['message']}};}
@@ -1 +1 @@
1
- import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';import{WorkflowError}from'./errors.js';import{STEP_TYPE_END,STEP_TYPE_ENTRY}from'./stepTypes.js';function snapshot(_0x5a9352){try{return void 0x0===_0x5a9352?null:JSON['parse'](JSON['stringify'](_0x5a9352));}catch{return String(_0x5a9352);}}export class WorkflowRunner{constructor({notifier:_0x4e5bdd,senderId:_0x4a4b16,workflow:_0x9dfc46}){if(!_0x4e5bdd)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20DNotifier\x20instance');if(!_0x4a4b16)throw new WorkflowError('WorkflowRunner\x20requires\x20senderId');if(!_0x9dfc46)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20workflow');this['notifier']=_0x4e5bdd,this['senderId']=_0x4a4b16,this['workflow']=_0x9dfc46;}async['run'](_0x852a86){var _0xa264a3,_0x4baccf,_0x284290;const _0x17fd46=null==_0x852a86?void 0x0:_0x852a86['input'],_0x4e5312={};let _0x5d8b7d=null,_0x37d0bb=null,_0xe46fe5=null;const _0x360b2f=Date['now']();if(this['workflow']['observability']){_0x5d8b7d=createWorkflowObservability({'appId':this['notifier']['appId'],'token':null!==(_0xa264a3=this['notifier']['authToken'])&&void 0x0!==_0xa264a3?_0xa264a3:null}),await _0x5d8b7d['registerWorkflow'](this['workflow']);const _0x1f7440=await _0x5d8b7d['startExecution']({'workflowId':this['workflow']['name'],'userId':this['senderId'],'input':_0x17fd46});_0x37d0bb=_0x1f7440['executionId'],_0xe46fe5=_0x1f7440['startedAt'];}let _0x40d7a8=null;if(_0x5d8b7d&&_0x37d0bb){const _0x4696f3=await _0x5d8b7d['recordStep'](_0x37d0bb,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':this['workflow']['name'],'status':'ok','latencyMs':0x0,'parentStepId':null,'input':snapshot(_0x17fd46),'state':snapshot(_0x4e5312)});_0x40d7a8=null!==(_0x4baccf=null==_0x4696f3?void 0x0:_0x4696f3['id'])&&void 0x0!==_0x4baccf?_0x4baccf:null;}const _0x391e42=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x17fd46,'state':_0x4e5312,'observability':_0x5d8b7d,'executionId':_0x37d0bb,'entryStepId':_0x40d7a8});let _0x5047fc,_0x1a0c54='ok',_0x53b5b3=null;try{_0x5047fc=await this['workflow']['entry'](_0x391e42);}catch(_0x2560fa){throw _0x1a0c54='error',_0x53b5b3={'message':null!==(_0x284290=null==_0x2560fa?void 0x0:_0x2560fa['message'])&&void 0x0!==_0x284290?_0x284290:String(_0x2560fa),'stack':null==_0x2560fa?void 0x0:_0x2560fa['stack']},_0x2560fa;}finally{if(_0x5d8b7d&&_0x37d0bb){await _0x5d8b7d['recordStep'](_0x37d0bb,{'type':STEP_TYPE_END,'kind':'end','label':this['workflow']['name'],'status':_0x1a0c54,'latencyMs':Date['now']()-_0x360b2f,'parentStepId':_0x391e42['getEndParentStepId'](),'output':snapshot('ok'===_0x1a0c54?_0x5047fc:null),'state':snapshot(_0x391e42['state']),'error':_0x53b5b3});const _0x4c58ba=new Date()['toISOString'](),_0x509b6d=_0x5d8b7d['getStepCount']();await _0x5d8b7d['completeExecution']({'executionId':_0x37d0bb,'status':_0x1a0c54,'endedAt':_0x4c58ba,'durationMs':Date['now']()-_0x360b2f,'stepCount':_0x509b6d,'error':_0x53b5b3,'result':'ok'===_0x1a0c54?_0x5047fc:null,'startedAt':_0xe46fe5});}}const _0x21f34b={'result':_0x5047fc,'state':_0x4e5312};return _0x37d0bb&&(_0x21f34b['executionId']=_0x37d0bb),_0x21f34b;}}
1
+ import{WorkflowContext}from'./context.js';import{createWorkflowObservability}from'./observability.js';import{WorkflowError}from'./errors.js';import{STEP_TYPE_END,STEP_TYPE_ENTRY}from'./stepTypes.js';function snapshot(_0x381596){try{return void 0x0===_0x381596?null:JSON['parse'](JSON['stringify'](_0x381596));}catch{return String(_0x381596);}}export class WorkflowRunner{constructor({notifier:_0x5497ed,senderId:_0x6e11ae,workflow:_0xb0c78c}){if(!_0x5497ed)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20DNotifier\x20instance');if(!_0x6e11ae)throw new WorkflowError('WorkflowRunner\x20requires\x20senderId');if(!_0xb0c78c)throw new WorkflowError('WorkflowRunner\x20requires\x20a\x20workflow');this['notifier']=_0x5497ed,this['senderId']=_0x6e11ae,this['workflow']=_0xb0c78c;}async['run'](_0x388069){var _0x51975e,_0x2815db,_0x410743;const _0x69ca90=null==_0x388069?void 0x0:_0x388069['input'],_0x5baa5e={};let _0x3909d8=null,_0x2753f9=null,_0x35f277=null;const _0x492b58=Date['now']();if(this['workflow']['observability']){_0x3909d8=createWorkflowObservability({'appId':this['notifier']['appId'],'token':null!==(_0x51975e=this['notifier']['authToken'])&&void 0x0!==_0x51975e?_0x51975e:null}),await _0x3909d8['registerWorkflow'](this['workflow']);const _0x5289a2=await _0x3909d8['startExecution']({'workflowId':this['workflow']['name'],'userId':this['senderId'],'input':_0x69ca90});_0x2753f9=_0x5289a2['executionId'],_0x35f277=_0x5289a2['startedAt'];}let _0x3f200d=null;if(_0x3909d8&&_0x2753f9){const _0x4b1fc6=await _0x3909d8['recordStep'](_0x2753f9,{'type':STEP_TYPE_ENTRY,'kind':'entry','label':this['workflow']['name'],'status':'ok','latencyMs':0x0,'parentStepId':null,'input':snapshot(_0x69ca90),'state':snapshot(_0x5baa5e)});_0x3f200d=null!==(_0x2815db=null==_0x4b1fc6?void 0x0:_0x4b1fc6['id'])&&void 0x0!==_0x2815db?_0x2815db:null;}const _0x30e634=new WorkflowContext({'notifier':this['notifier'],'senderId':this['senderId'],'workflow':this['workflow'],'input':_0x69ca90,'state':_0x5baa5e,'observability':_0x3909d8,'executionId':_0x2753f9,'entryStepId':_0x3f200d});let _0x1d0e25,_0x4652a9='ok',_0x66d3a6=null;try{_0x1d0e25=await this['workflow']['entry'](_0x30e634);}catch(_0x1cd726){throw _0x4652a9='error',_0x66d3a6={'message':null!==(_0x410743=null==_0x1cd726?void 0x0:_0x1cd726['message'])&&void 0x0!==_0x410743?_0x410743:String(_0x1cd726),'stack':null==_0x1cd726?void 0x0:_0x1cd726['stack']},_0x1cd726;}finally{if(_0x3909d8&&_0x2753f9){await _0x3909d8['recordStep'](_0x2753f9,{'type':STEP_TYPE_END,'kind':'end','label':this['workflow']['name'],'status':_0x4652a9,'latencyMs':Date['now']()-_0x492b58,'parentStepId':_0x30e634['getEndParentStepId'](),'output':snapshot('ok'===_0x4652a9?_0x1d0e25:null),'state':snapshot(_0x30e634['state']),'error':_0x66d3a6});const _0xb57319=new Date()['toISOString'](),_0x7eac3a=_0x3909d8['getStepCount']();await _0x3909d8['completeExecution']({'executionId':_0x2753f9,'status':_0x4652a9,'endedAt':_0xb57319,'durationMs':Date['now']()-_0x492b58,'stepCount':_0x7eac3a,'error':_0x66d3a6,'result':'ok'===_0x4652a9?_0x1d0e25:null,'startedAt':_0x35f277});}}const _0x35fc34={'result':_0x1d0e25,'state':_0x5baa5e};return _0x2753f9&&(_0x35fc34['executionId']=_0x2753f9),_0x35fc34;}}
@@ -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 STRUCTURAL_STEP_TYPES=['Agent','Parallel','Entry','End','Custom'];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'};const LEGACY_KIND_TO_API={'ai_call':'sendAI','vector_call':'search'};export function toLogStepType(_0x1adfb2){if(null==_0x1adfb2||''===String(_0x1adfb2)['trim']())return'Custom';const _0x49d239=String(_0x1adfb2);if(LOG_TYPE_BY_API[_0x49d239])return LOG_TYPE_BY_API[_0x49d239];const _0x3d1e36=_0x49d239['toLowerCase']();for(const [_0x3ba3a1,_0x18db2f]of Object['entries'](LOG_TYPE_BY_API))if(_0x3ba3a1['toLowerCase']()===_0x3d1e36)return _0x18db2f;return _0x49d239;}export function resolveApiName(_0x198780){const _0x2ca50c=null==_0x198780?void 0x0:_0x198780['kind'];if(null==_0x2ca50c||''===String(_0x2ca50c)['trim']())return null;const _0x59f073=String(_0x2ca50c);return LEGACY_KIND_TO_API[_0x59f073]?LEGACY_KIND_TO_API[_0x59f073]:'agent'===_0x59f073||SDK_API_STEP_TYPES['includes'](_0x59f073)||'semanticSearch'===_0x59f073?_0x59f073:null;}export function resolveStepType(_0x142f25){if(null!=(null==_0x142f25?void 0x0:_0x142f25['type'])&&''!==String(_0x142f25['type'])['trim']()){const _0x44f1a2=String(_0x142f25['type'])['trim']();return STRUCTURAL_STEP_TYPES['includes'](_0x44f1a2)||Object['values'](LOG_TYPE_BY_API)['includes'](_0x44f1a2)?_0x44f1a2:toLogStepType(_0x44f1a2);}const _0x5c3605=resolveApiName(_0x142f25);return _0x5c3605?toLogStepType(_0x5c3605):'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 STRUCTURAL_STEP_TYPES=['Agent','Parallel','Entry','End','Custom'];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'};const LEGACY_KIND_TO_API={'ai_call':'sendAI','vector_call':'search'};export function toLogStepType(_0xaa69f){if(null==_0xaa69f||''===String(_0xaa69f)['trim']())return'Custom';const _0x59f3e9=String(_0xaa69f);if(LOG_TYPE_BY_API[_0x59f3e9])return LOG_TYPE_BY_API[_0x59f3e9];const _0x2164c2=_0x59f3e9['toLowerCase']();for(const [_0x3d524f,_0x27aa00]of Object['entries'](LOG_TYPE_BY_API))if(_0x3d524f['toLowerCase']()===_0x2164c2)return _0x27aa00;return _0x59f3e9;}export function resolveApiName(_0x1cd88d){const _0x47a385=null==_0x1cd88d?void 0x0:_0x1cd88d['kind'];if(null==_0x47a385||''===String(_0x47a385)['trim']())return null;const _0x2caead=String(_0x47a385);return LEGACY_KIND_TO_API[_0x2caead]?LEGACY_KIND_TO_API[_0x2caead]:'agent'===_0x2caead||SDK_API_STEP_TYPES['includes'](_0x2caead)||'semanticSearch'===_0x2caead?_0x2caead:null;}export function resolveStepType(_0xb9f51e){if(null!=(null==_0xb9f51e?void 0x0:_0xb9f51e['type'])&&''!==String(_0xb9f51e['type'])['trim']()){const _0x522b46=String(_0xb9f51e['type'])['trim']();return STRUCTURAL_STEP_TYPES['includes'](_0x522b46)||Object['values'](LOG_TYPE_BY_API)['includes'](_0x522b46)?_0x522b46:toLogStepType(_0x522b46);}const _0x4896b8=resolveApiName(_0xb9f51e);return _0x4896b8?toLogStepType(_0x4896b8):'Custom';}
@@ -9,10 +9,22 @@ export class Workflow {
9
9
  description: string | undefined;
10
10
  observability: boolean;
11
11
  entry: (ctx: import("./context.js").WorkflowContext) => Promise<any>;
12
- _agents: Map<string, import("./agent.js").Agent>;
12
+ _agents: Map<string, AgentRegistration>;
13
13
  _registeredWithObservability: boolean;
14
- registerAgent(name: string, agent: import("./agent.js").Agent): this;
15
- registerAgents(agents: Record<string, import("./agent.js").Agent>): this;
14
+ _listenNotifier: import("../dnotifier.js").DNotifier | null;
15
+ registerAgent(name: string, agentOrRemote: AgentRegistration): this;
16
+ registerAgents(agents: Record<string, AgentRegistration>): this;
16
17
  getAgent(name: string): import("./agent.js").Agent | undefined;
18
+ getAgentRegistration(name: string): AgentRegistration | undefined;
19
+ hasLocalAgent(name: string): boolean;
20
+ listen(notifier: import("../dnotifier.js").DNotifier): this;
21
+ _handleRemoteInvoke(notifier: import("../dnotifier.js").DNotifier, msg: {
22
+ metadata: object;
23
+ payload: any;
24
+ }, data: object): Promise<void>;
17
25
  }
26
+ export type RemoteAgentRegistration = {
27
+ receiverId: string;
28
+ };
29
+ export type AgentRegistration = import("./agent.js").Agent | RemoteAgentRegistration;
18
30
  //# sourceMappingURL=workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow/workflow.js"],"names":[],"mappings":"AAmBA;IASE,yDAPW;QACN,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,eAAe,KAAK,OAAO,CAAC,GAAC,CAAC,CAAC;KACpE,EAiBH;IAPC,aAAuB;IACvB,gCAAoD;IACpD,uBAA2C;IAC3C,aAdgB,OAAO,cAAc,EAAE,eAAe,KAAK,OAAO,CAAC,GAAC,CAAC,CAcnD;IAElB,SADW,GAAG,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC,CAC1B;IACxB,sCAAyC;IAO3C,oBAHW,MAAM,SACN,OAAO,YAAY,EAAE,KAAK,QAWpC;IAKD,uBAFW,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,KAAK,CAAC,QAOpD;IAMD,eAHW,MAAM,GACJ,OAAO,YAAY,EAAE,KAAK,GAAG,SAAS,CAIlD;CACF"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow/workflow.js"],"names":[],"mappings":"AAgCA;IASE,yDAPW;QACN,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,eAAe,KAAK,OAAO,CAAC,GAAC,CAAC,CAAC;KACpE,EAmBH;IATC,aAAuB;IACvB,gCAAoD;IACpD,uBAA2C;IAC3C,aAdgB,OAAO,cAAc,EAAE,eAAe,KAAK,OAAO,CAAC,GAAC,CAAC,CAcnD;IAElB,SADW,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CACjB;IACxB,sCAAyC;IAEzC,iBADW,OAAO,iBAAiB,EAAE,SAAS,GAAG,IAAI,CAC1B;IAO7B,oBAHW,MAAM,iBACN,iBAAiB,QAiB3B;IAKD,uBAFW,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,QAO3C;IAOD,eAHW,MAAM,GACJ,OAAO,YAAY,EAAE,KAAK,GAAG,SAAS,CAMlD;IAMD,2BAHW,MAAM,GACJ,iBAAiB,GAAG,SAAS,CAIzC;IAMD,oBAHW,MAAM,GACJ,OAAO,CAInB;IAQD,iBAFW,OAAO,iBAAiB,EAAE,SAAS,QAY7C;IAQD,8BAJW,OAAO,iBAAiB,EAAE,SAAS,OACnC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,GAAC,CAAA;KAAE,QAChC,MAAM,iBAqEhB;CACF;sCAtLY;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE;gCACtB,OAAO,YAAY,EAAE,KAAK,GAAG,uBAAuB"}
@@ -1 +1 @@
1
- import{WorkflowError}from'./errors.js';function normalizeDescription(_0x30a2df){if(null==_0x30a2df||''===_0x30a2df)return;if('string'!=typeof _0x30a2df)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20a\x20string');const _0x258a04=_0x30a2df['trim']();if(_0x258a04['length']>0x64)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20at\x20most\x20100\x20characters');return _0x258a04['length']>0x0?_0x258a04:void 0x0;}export class Workflow{constructor({name:_0xb1b324,description:_0xcd7d4,observability:_0x1f691b=!0x1,entry:_0x4d8813}){if(!_0xb1b324||'string'!=typeof _0xb1b324)throw new WorkflowError('Workflow\x20name\x20is\x20required');if('function'!=typeof _0x4d8813)throw new WorkflowError('Workflow\x20entry\x20must\x20be\x20a\x20function');this['name']=_0xb1b324['trim'](),this['description']=normalizeDescription(_0xcd7d4),this['observability']=Boolean(_0x1f691b),this['entry']=_0x4d8813,this['_agents']=new Map(),this['_registeredWithObservability']=!0x1;}['registerAgent'](_0x3299bb,_0x2c54b2){if(!_0x3299bb||'string'!=typeof _0x3299bb)throw new WorkflowError('Agent\x20registration\x20name\x20is\x20required');if(!_0x2c54b2||'function'!=typeof _0x2c54b2['run'])throw new WorkflowError('Invalid\x20agent\x20for\x20\x22'+_0x3299bb+'\x22');return this['_agents']['set'](_0x3299bb,_0x2c54b2),this;}['registerAgents'](_0x451481){for(const [_0x56e333,_0x564a90]of Object['entries'](_0x451481))this['registerAgent'](_0x56e333,_0x564a90);return this;}['getAgent'](_0x8d070a){return this['_agents']['get'](_0x8d070a);}}
1
+ 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(_0x2e43c6){if(null==_0x2e43c6||''===_0x2e43c6)return;if('string'!=typeof _0x2e43c6)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20a\x20string');const _0x32e312=_0x2e43c6['trim']();if(_0x32e312['length']>0x64)throw new WorkflowError('Workflow\x20description\x20must\x20be\x20at\x20most\x20100\x20characters');return _0x32e312['length']>0x0?_0x32e312:void 0x0;}export class Workflow{constructor({name:_0x48a06f,description:_0x38f5ad,observability:_0x54bff6=!0x1,entry:_0x2bd03f}){if(!_0x48a06f||'string'!=typeof _0x48a06f)throw new WorkflowError('Workflow\x20name\x20is\x20required');if('function'!=typeof _0x2bd03f)throw new WorkflowError('Workflow\x20entry\x20must\x20be\x20a\x20function');this['name']=_0x48a06f['trim'](),this['description']=normalizeDescription(_0x38f5ad),this['observability']=Boolean(_0x54bff6),this['entry']=_0x2bd03f,this['_agents']=new Map(),this['_registeredWithObservability']=!0x1,this['_listenNotifier']=null;}['registerAgent'](_0x5ca853,_0x110547){if(!_0x5ca853||'string'!=typeof _0x5ca853)throw new WorkflowError('Agent\x20registration\x20name\x20is\x20required');if(isRemoteAgentRef(_0x110547))return this['_agents']['set'](_0x5ca853,{'receiverId':_0x110547['receiverId']['trim']()}),this;if(!_0x110547||'function'!=typeof _0x110547['run'])throw new WorkflowError('Invalid\x20agent\x20for\x20\x22'+_0x5ca853+'\x22\x20(expected\x20Agent\x20or\x20{\x20receiverId\x20})');return this['_agents']['set'](_0x5ca853,_0x110547),this;}['registerAgents'](_0x129ff2){for(const [_0xe06e53,_0x42c5e5]of Object['entries'](_0x129ff2))this['registerAgent'](_0xe06e53,_0x42c5e5);return this;}['getAgent'](_0x4b5896){const _0x5ee2bc=this['_agents']['get'](_0x4b5896);if(_0x5ee2bc&&!isRemoteAgentRef(_0x5ee2bc))return _0x5ee2bc;}['getAgentRegistration'](_0x4d4566){return this['_agents']['get'](_0x4d4566);}['hasLocalAgent'](_0x48e942){return Boolean(this['getAgent'](_0x48e942));}['listen'](_0x4608aa){if(!_0x4608aa)throw new WorkflowError('workflow.listen\x20requires\x20a\x20DNotifier\x20instance');return this['_listenNotifier']&&this['_listenNotifier']!==_0x4608aa&&this['_listenNotifier']['_unregisterWorkflowListener'](this),this['_listenNotifier']=_0x4608aa,_0x4608aa['_registerWorkflowListener'](this),this;}async['_handleRemoteInvoke'](_0x335f63,_0x2a0f20,_0x11c685){var _0x4662a3,_0x2ff4bc,_0x29a593,_0x9d0c6f,_0x1909c8,_0x470772,_0x2ea94b,_0x20e263;const _0x515170=_0x11c685['agentName'],_0x114b90=_0x11c685['correlationId'],_0x253eec='string'==typeof _0x11c685['replyTo']&&_0x11c685['replyTo']['trim']()||bareUserId(_0x335f63['appId'],null===(_0x4662a3=null==_0x2a0f20?void 0x0:_0x2a0f20['metadata'])||void 0x0===_0x4662a3?void 0x0:_0x4662a3['sender']);if(!_0x114b90||!_0x253eec)return;if(!this['hasLocalAgent'](_0x515170))return void await sendRemoteAgentError(_0x335f63,{'senderId':_0x335f63['userId'],'receiverId':_0x253eec,'correlationId':_0x114b90,'message':'Agent\x20not\x20hosted:\x20'+_0x515170});const _0x40fac5=_0x11c685['state']&&'object'==typeof _0x11c685['state']&&!Array['isArray'](_0x11c685['state'])?{..._0x11c685['state']}:{};let _0x4c75a2=null;const _0x450fe9=null!==(_0x29a593=null===(_0x2ff4bc=_0x11c685['trace'])||void 0x0===_0x2ff4bc?void 0x0:_0x2ff4bc['executionId'])&&void 0x0!==_0x29a593?_0x29a593:null;_0x450fe9&&this['observability']&&(_0x4c75a2=createWorkflowObservability({'appId':_0x335f63['appId'],'token':null!==(_0x9d0c6f=_0x335f63['authToken'])&&void 0x0!==_0x9d0c6f?_0x9d0c6f:null,'appendOnly':!0x0}),await _0x4c75a2['registerWorkflow'](this));const _0x30e1d9=new WorkflowContext({'notifier':_0x335f63,'senderId':_0x335f63['userId'],'workflow':this,'input':null!==(_0x1909c8=_0x11c685['input'])&&void 0x0!==_0x1909c8?_0x1909c8:null,'state':_0x40fac5,'observability':_0x4c75a2,'executionId':_0x450fe9,'traceParentStepId':null!==(_0x2ea94b=null===(_0x470772=_0x11c685['trace'])||void 0x0===_0x470772?void 0x0:_0x470772['parentStepId'])&&void 0x0!==_0x2ea94b?_0x2ea94b:null});try{const _0x48dda5=await _0x30e1d9['runAgent'](_0x515170,{'input':void 0x0!==_0x11c685['input']?_0x11c685['input']:_0x30e1d9['input']});await sendRemoteAgentResult(_0x335f63,{'senderId':_0x335f63['userId'],'receiverId':_0x253eec,'correlationId':_0x114b90,'output':_0x48dda5,'state':_0x30e1d9['state']});}catch(_0x1acf2d){await sendRemoteAgentError(_0x335f63,{'senderId':_0x335f63['userId'],'receiverId':_0x253eec,'correlationId':_0x114b90,'message':null!==(_0x20e263=null==_0x1acf2d?void 0x0:_0x1acf2d['message'])&&void 0x0!==_0x20e263?_0x20e263:String(_0x1acf2d)});}}}
@@ -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:_0x358c75=null,token:_0x542eb2=null,requestTimeoutMs:_0x1221e2=0x1388}={}){this['appId']=_0x358c75,this['token']=_0x542eb2,this['requestTimeoutMs']=_0x1221e2;}['configure']({appId:_0x3d213f,token:_0x50ce5d,requestTimeoutMs:_0x146420}={}){void 0x0!==_0x3d213f&&(this['appId']=_0x3d213f),void 0x0!==_0x50ce5d&&(this['token']=_0x50ce5d),void 0x0!==_0x146420&&(this['requestTimeoutMs']=_0x146420);}['_transport'](_0x522fcd){const _0x5622b0=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x522fcd,'headers':_0x5622b0,'timeoutMs':this['requestTimeoutMs']});}async['_post'](_0x5d1232,_0x1349d8){if(this['token'])try{await this['_transport'](_0x5d1232)['send'](_0x1349d8);}catch{}}async['registerWorkflow'](_0x3de7c5){const _0x306678={'appId':_0x3de7c5['appId'],'workflowId':_0x3de7c5['workflowId'],'name':_0x3de7c5['name']};return null!=_0x3de7c5['description']&&''!==_0x3de7c5['description']&&(_0x306678['description']=_0x3de7c5['description']),await this['_post'](DNotifierEndpoints['workflowRegisterUrl'],_0x306678),{'ok':!0x0};}async['createExecution'](_0x51dce5){var _0xb1daa2;const _0x1ee26b=null!==(_0xb1daa2=_0x51dce5['id'])&&void 0x0!==_0xb1daa2?_0xb1daa2:shortId('exec'),_0x50c83c={'id':_0x1ee26b,'appId':_0x51dce5['appId'],'workflowId':_0x51dce5['workflowId'],'userId':_0x51dce5['userId'],'status':'in_progress','stepCount':0x0,'startedAt':_0x51dce5['startedAt']};return setJsonColumn(_0x50c83c,'input',_0x51dce5['input']),await this['_post'](DNotifierEndpoints['workflowExecutionsUrl'],_0x50c83c),{'executionId':_0x1ee26b,'record':_0x50c83c};}async['updateExecution'](_0x5a5887,_0x285960){const _0x5a9a5a={'id':_0x5a5887,'status':_0x285960['status'],'endedAt':_0x285960['endedAt'],'durationMs':_0x285960['durationMs'],'stepCount':_0x285960['stepCount']};return setJsonColumn(_0x5a9a5a,'error',_0x285960['error']),setJsonColumn(_0x5a9a5a,'result',_0x285960['result']),await this['_post'](DNotifierEndpoints['workflowExecutionCompleteUrl'](_0x5a5887),_0x5a9a5a),{'ok':!0x0,'record':_0x5a9a5a};}async['addStep'](_0x9b33a0,_0x226aa7){var _0x41eede,_0x1933d0,_0x58d294,_0x4d2761,_0x5618de,_0x1c69cb;const _0x26aa9c=resolveStepType(_0x226aa7),_0x26e480=null!==(_0x58d294=null!==(_0x1933d0=null!==(_0x41eede=_0x226aa7['agentName'])&&void 0x0!==_0x41eede?_0x41eede:_0x226aa7['kind'])&&void 0x0!==_0x1933d0?_0x1933d0:_0x226aa7['apiName'])&&void 0x0!==_0x58d294?_0x58d294:null,_0xc2d593={'id':_0x226aa7['id'],'executionId':_0x9b33a0,'kind':_0x26e480,'label':_0x226aa7['label'],'type':_0x26aa9c,'step_type':_0x26aa9c,'status':_0x226aa7['status'],'executedAt':_0x226aa7['executedAt'],'latencyMs':null!==(_0x4d2761=_0x226aa7['latencyMs'])&&void 0x0!==_0x4d2761?_0x4d2761:0x0,'tokensIn':null!==(_0x5618de=_0x226aa7['tokensIn'])&&void 0x0!==_0x5618de?_0x5618de:0x0,'tokensOut':null!==(_0x1c69cb=_0x226aa7['tokensOut'])&&void 0x0!==_0x1c69cb?_0x1c69cb:0x0};return null!=_0x226aa7['apiName']&&''!==_0x226aa7['apiName']&&(_0xc2d593['apiName']=_0x226aa7['apiName']),null!=_0x226aa7['agentName']&&''!==_0x226aa7['agentName']&&(_0xc2d593['agentName']=_0x226aa7['agentName']),null!=_0x226aa7['model']&&''!==_0x226aa7['model']&&(_0xc2d593['model']='string'==typeof _0x226aa7['model']?_0x226aa7['model']:String(_0x226aa7['model'])),setJsonColumn(_0xc2d593,'input',_0x226aa7['input']),setJsonColumn(_0xc2d593,'output',_0x226aa7['output']),setJsonColumn(_0xc2d593,'state',_0x226aa7['state']),setJsonColumn(_0xc2d593,'error',_0x226aa7['error']),null!=_0x226aa7['parentStepId']&&''!==_0x226aa7['parentStepId']&&(_0xc2d593['parentStepId']=_0x226aa7['parentStepId']),null!=_0x226aa7['siblingIndex']&&''!==_0x226aa7['siblingIndex']&&(_0xc2d593['siblingIndex']=_0x226aa7['siblingIndex']),null!=_0x226aa7['branchKey']&&''!==_0x226aa7['branchKey']&&(_0xc2d593['branchKey']=_0x226aa7['branchKey']),await this['_post'](DNotifierEndpoints['workflowExecutionStepsUrl'](_0x9b33a0),_0xc2d593),{'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:_0xd8d010=null,token:_0xecd18d=null,requestTimeoutMs:_0x5df937=0x1388}={}){this['appId']=_0xd8d010,this['token']=_0xecd18d,this['requestTimeoutMs']=_0x5df937;}['configure']({appId:_0x3d228a,token:_0x364177,requestTimeoutMs:_0x4152f8}={}){void 0x0!==_0x3d228a&&(this['appId']=_0x3d228a),void 0x0!==_0x364177&&(this['token']=_0x364177),void 0x0!==_0x4152f8&&(this['requestTimeoutMs']=_0x4152f8);}['_transport'](_0x377ef8){const _0x33ddbd=this['token']?{'authorization':''+this['token']}:{};return new HttpTransport({'url':_0x377ef8,'headers':_0x33ddbd,'timeoutMs':this['requestTimeoutMs']});}async['_post'](_0x6cd4bf,_0x45d7ac){if(this['token'])try{await this['_transport'](_0x6cd4bf)['send'](_0x45d7ac);}catch{}}async['registerWorkflow'](_0x108e98){const _0x4f4134={'appId':_0x108e98['appId'],'workflowId':_0x108e98['workflowId'],'name':_0x108e98['name']};return null!=_0x108e98['description']&&''!==_0x108e98['description']&&(_0x4f4134['description']=_0x108e98['description']),await this['_post'](DNotifierEndpoints['workflowRegisterUrl'],_0x4f4134),{'ok':!0x0};}async['createExecution'](_0x4c2f15){var _0x208a01;const _0x488c8d=null!==(_0x208a01=_0x4c2f15['id'])&&void 0x0!==_0x208a01?_0x208a01:shortId('exec'),_0x18c976={'id':_0x488c8d,'appId':_0x4c2f15['appId'],'workflowId':_0x4c2f15['workflowId'],'userId':_0x4c2f15['userId'],'status':'in_progress','stepCount':0x0,'startedAt':_0x4c2f15['startedAt']};return setJsonColumn(_0x18c976,'input',_0x4c2f15['input']),await this['_post'](DNotifierEndpoints['workflowExecutionsUrl'],_0x18c976),{'executionId':_0x488c8d,'record':_0x18c976};}async['updateExecution'](_0x2cfa7e,_0x433063){const _0x2503d7={'id':_0x2cfa7e,'status':_0x433063['status'],'endedAt':_0x433063['endedAt'],'durationMs':_0x433063['durationMs'],'stepCount':_0x433063['stepCount']};return setJsonColumn(_0x2503d7,'error',_0x433063['error']),setJsonColumn(_0x2503d7,'result',_0x433063['result']),await this['_post'](DNotifierEndpoints['workflowExecutionCompleteUrl'](_0x2cfa7e),_0x2503d7),{'ok':!0x0,'record':_0x2503d7};}async['addStep'](_0x46f7cf,_0x12ac64){var _0x246484,_0x4f4097,_0x29947d,_0x3c8eb3,_0x17b37c,_0x28c0bb;const _0x5a9713=resolveStepType(_0x12ac64),_0x4d2845=null!==(_0x29947d=null!==(_0x4f4097=null!==(_0x246484=_0x12ac64['agentName'])&&void 0x0!==_0x246484?_0x246484:_0x12ac64['kind'])&&void 0x0!==_0x4f4097?_0x4f4097:_0x12ac64['apiName'])&&void 0x0!==_0x29947d?_0x29947d:null,_0x2a216d={'id':_0x12ac64['id'],'executionId':_0x46f7cf,'kind':_0x4d2845,'label':_0x12ac64['label'],'type':_0x5a9713,'step_type':_0x5a9713,'status':_0x12ac64['status'],'executedAt':_0x12ac64['executedAt'],'latencyMs':null!==(_0x3c8eb3=_0x12ac64['latencyMs'])&&void 0x0!==_0x3c8eb3?_0x3c8eb3:0x0,'tokensIn':null!==(_0x17b37c=_0x12ac64['tokensIn'])&&void 0x0!==_0x17b37c?_0x17b37c:0x0,'tokensOut':null!==(_0x28c0bb=_0x12ac64['tokensOut'])&&void 0x0!==_0x28c0bb?_0x28c0bb:0x0};return null!=_0x12ac64['apiName']&&''!==_0x12ac64['apiName']&&(_0x2a216d['apiName']=_0x12ac64['apiName']),null!=_0x12ac64['agentName']&&''!==_0x12ac64['agentName']&&(_0x2a216d['agentName']=_0x12ac64['agentName']),null!=_0x12ac64['model']&&''!==_0x12ac64['model']&&(_0x2a216d['model']='string'==typeof _0x12ac64['model']?_0x12ac64['model']:String(_0x12ac64['model'])),setJsonColumn(_0x2a216d,'input',_0x12ac64['input']),setJsonColumn(_0x2a216d,'output',_0x12ac64['output']),setJsonColumn(_0x2a216d,'state',_0x12ac64['state']),setJsonColumn(_0x2a216d,'error',_0x12ac64['error']),null!=_0x12ac64['parentStepId']&&''!==_0x12ac64['parentStepId']&&(_0x2a216d['parentStepId']=_0x12ac64['parentStepId']),null!=_0x12ac64['siblingIndex']&&''!==_0x12ac64['siblingIndex']&&(_0x2a216d['siblingIndex']=_0x12ac64['siblingIndex']),null!=_0x12ac64['branchKey']&&''!==_0x12ac64['branchKey']&&(_0x2a216d['branchKey']=_0x12ac64['branchKey']),await this['_post'](DNotifierEndpoints['workflowExecutionStepsUrl'](_0x46f7cf),_0x2a216d),{'ok':!0x0};}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnotifier-realtime/dnotifier",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "Real-time communication & AI SDK",
5
5
  "main": "dist/dnotifier.js",
6
6
  "types": "dist/dnotifier.d.ts",
@@ -44,6 +44,7 @@
44
44
  "test": "echo \"Error: no test specified\" && exit 1",
45
45
  "start": "node index.js",
46
46
  "build": "tsc && npx esbuild src/dnotifier.js --bundle --format=cjs --platform=node --outfile=dist/dnotifier.cjs --external:ws",
47
+ "prepublishOnly": "node scripts/assert-publish-ok.js",
47
48
  "publishprod": "node scripts/publish-prod.js"
48
49
  },
49
50
  "homepage": "https://dnotifier.com"