@blue-labs/document-processor 1.36.0 → 1.37.1

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.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var be=Object.create;var j=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Se=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Ne=(a,e,t)=>e in a?j(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var Ie=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Pe(e))!Ce.call(a,o)&&o!==t&&j(a,o,{get:()=>e[o],enumerable:!(n=Te(e,o))||n.enumerable});return a};var z=(a,e,t)=>(t=a!=null?be(Se(a)):{},Ie(e||!a||!a.__esModule?j(t,"default",{value:a,enumerable:!0}):t,a));var l=(a,e,t)=>Ne(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@blue-repository/core-dev"),m=require("@blue-labs/language"),v=require("@blue-labs/shared-utils"),C=require("@blue-repository/myos-dev"),S=(...a)=>a.map((e,t)=>{if(typeof e!="string")return"";if(t===0&&e==="/")return"/";const n=t>0?e.replace(/^\/+/,""):e;return t<a.length-1?n.replace(/\/+$/,""):n}).filter(Boolean).join("/").replace(/\/{2,}/g,"/");class Y{constructor(e,t,n,o){l(this,"actions",[]);this.getDocument=e,this.taskInfo=t,this.blue=n,this.onFlush=o}get(e){const t=this.getDocument(),n=S(this.taskInfo.nodePath,e);return t.get(n)}addPatch(e){this.actions.push({kind:"patch",patch:{...e,path:S(this.taskInfo.nodePath,e.path)}})}emitEvent(e){const t=this.taskInfo.event,n=t.trace??[],o={...e,source:e.source??"internal",originNodePath:e.originNodePath??this.taskInfo.nodePath,rootEvent:e.rootEvent??t.rootEvent??t,trace:[...n],emissionType:e.emissionType??t.emissionType};this.actions.push({kind:"event",event:o})}async flush(){var t;if(!this.actions.length)return[];const e=[...this.actions];return this.actions.length=0,await((t=this.onFlush)==null?void 0:t.call(this,e)),e}getNodePath(){return this.taskInfo.nodePath}resolvePath(e){return S(this.taskInfo.nodePath,e)}getTaskInfo(){return this.taskInfo}getBlue(){return this.blue}loadExternalModule(){throw new Error("Not implemented")}loadBlueContent(e){const t=this.blue.getNodeProvider().fetchFirstByBlueId(e);if(!t)throw new Error(`Blue node not found for blueId: ${e}`);return Promise.resolve(JSON.stringify(this.blue.nodeToJson(t)))}}class _ extends Error{constructor(e,t){super(`Cannot apply patch ${JSON.stringify(e)}`),this.patch=e,this.cause=t,this.name="PatchApplicationError"}}class W extends Error{constructor(e,t,n){super(`Patch ${JSON.stringify(e)} touches "${e.op==="move"||e.op==="copy"?`${e.from} → ${e.path}`:e.path}" which is inside embedded document "${t}" (Process Embedded @ "${n}")`),this.patch=e,this.offendingPath=t,this.contractNodePath=n,this.name="EmbeddedDocumentModificationError"}}class Z extends Error{constructor(e,t){super(`Failed to evaluate expression "${e}"`),this.code=e,this.cause=t,this.name="ExpressionEvaluationError"}}class ee extends Error{constructor(e,t){super(`Failed to evaluate code block "${e}"`),this.code=e,this.cause=t,this.name="CodeBlockEvaluationError"}}function B(a){return v.deepFreeze(a)}function M(a){return a.clone()}function D(a,e,t="/",n=[]){const o=a.getContracts()??{};for(const[r,s]of Object.entries(o))if(e.isTypeOf(s,h.ProcessEmbeddedSchema)){const d=e.nodeToSchemaOutput(s,h.ProcessEmbeddedSchema).paths??[];for(const u of d)n.push({absPath:S(t,u),contractPath:S(t,`contracts/${r}`)})}for(const[r,s]of Object.entries(a.getProperties()??{}))D(s,e,S(t,r),n);return n}function R(a,e){return a===e||a.startsWith(e.endsWith("/")?e:e+"/")}function H(a,e){if(!e.length)return a;let t=M(a);for(const n of e)try{t=m.applyBlueNodePatch(t,n,!0)}catch(o){throw new _(n,o)}return B(t)}function w(a){return a!=null}function N(a){return a instanceof m.BlueNode}class ke{constructor(e=[],t=(n,o)=>n<o?-1:n>o?1:0){l(this,"data");l(this,"length");l(this,"compare");if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,o=t[e];for(;e>0;){const r=e-1>>1,s=t[r];if(n(o,s)>=0)break;t[e]=s,e=r}t[e]=o}_down(e){const{data:t,compare:n}=this,o=this.length>>1,r=t[e];for(;e<o;){let s=(e<<1)+1;const i=s+1;if(i<this.length&&n(t[i],t[s])<0&&(s=i),n(t[s],r)>=0)break;t[e]=t[s],e=s}t[e]=r}}const Be=(a,e,t,n,o,r)=>[-a,e,t,n,o,r],Oe=(a,e)=>{for(let t=0;t<a.key.length;t++){const n=a.key[t],o=e.key[t];if(n!==o)return typeof n=="number"&&typeof o=="number"?n-o:typeof n=="string"&&typeof o=="string"?n.localeCompare(o):0}return 0};class Me{constructor(){l(this,"queue");this.queue=new ke([],Oe)}push(e){this.queue.push(e)}pop(){return this.queue.pop()}get length(){return this.queue.length}}class qe{constructor(e=[]){l(this,"processors",new Map);l(this,"typeOrder",new Map);e.forEach((t,n)=>this.register(t,n))}register(e,t){if(this.processors.has(e.contractBlueId))throw new Error(`Processor for ${e.contractType} already registered`);this.processors.set(e.contractBlueId,e),this.typeOrder.has(e.contractBlueId)||this.typeOrder.set(e.contractBlueId,t??this.typeOrder.size)}get(e){if(!e)return;const t=e.getBlueId();if(t)return this.processors.get(t)}orderOf(e){if(!e)return 0;const t=e.getBlueId();return t?this.typeOrder.get(t)??0:0}values(){return this.processors.values()}}const O=class O{constructor(){l(this,"isEnabled");this.isEnabled=process.env.TRACE_BLUE_ENABLED!=="false"}makeHop(e,t){return`${e}#${t}`}shouldTrace(){return this.isEnabled}addHop(e,t,n){if(!this.shouldTrace())return{...e};const o=e.trace??[],s=[...o.length>=O.MAX_TRACE_LENGTH?o.slice(o.length-(O.MAX_TRACE_LENGTH-1)):o,this.makeHop(t,n)];return{...e,trace:s}}getTrace(e){return e.trace??[]}clearTrace(e){return{...e,trace:[]}}isTracingEnabled(){return this.isEnabled}};l(O,"MAX_TRACE_LENGTH",128);let x=O;function $e(a){return Object.entries(a.getContracts()??{})}const De=64;class Ae{constructor(e,t,n,o,r){l(this,"traceManager");this.blue=e,this.registry=t,this.queue=n,this.getNextTaskId=o,this.getNextEventSeq=r,this.traceManager=new x}async route(e,t,n,o,r=0){var c;if(n.seq===void 0&&(n.seq=this.getNextEventSeq()),t.length===0){if(n.dispatchPath){const d=n.dispatchPath.split("/").filter(Boolean),u={...n};return delete u.dispatchPath,this.route(e,d,u,o,r)}if(n.source==="channel"&&n.originNodePath&&n.originNodePath!=="/"){const d=((c=n.originNodePath)==null?void 0:c.split("/").filter(Boolean))??[];return this.route(e,d,n,o,r)}}const s=S("/",t.join("/")),i=e.get(s);N(i)&&await this.traverseContracts({doc:e,node:i,nodePath:s,event:n,afterTaskId:o,pathSegments:t,inlineDepth:r})}async traverseContracts(e){const{doc:t,node:n,nodePath:o,event:r,afterTaskId:s,pathSegments:i,inlineDepth:c}=e;if(!this.shouldSkipForChannel(r,o))for(const[d,u]of $e(n)){if(!u.getType())continue;const p=this.registry.get(u.getType());if(!p){console.warn(`No processor registered for contract: ${d}`);continue}const f={nodePath:o,contractName:d,contractNode:u,event:r},g=new Y(()=>t,f,this.blue);if(p.supports(r,u,g,d))switch(p.role){case"adapter":await this.processAdapter({cp:p,event:r,contractNode:u,ctx:g,contractName:d,doc:t,afterTaskId:s,inlineDepth:c});break;case"handler":this.scheduleHandler({contractNode:u,contractName:d,nodePath:o,event:r,depth:i.length,afterTaskId:s});break}}}async processAdapter(e){var T;const{cp:t,event:n,contractNode:o,ctx:r,contractName:s,doc:i,afterTaskId:c,inlineDepth:d}=e;if(d>=De)throw new Error("Adapter recursion limit reached");const u=this.traceManager.addHop(n,((T=r.getTaskInfo())==null?void 0:T.nodePath)??"",s);await t.handle(u,o,r,s);const p=await r.flush();if(p.find(b=>b.kind==="patch"))throw new Error(`Contract "${s}" (adapter) attempted to patch the document`);const g=p.filter(b=>b.kind==="event");for(const b of g)await this.route(i,[],b.event,c,d+1)}scheduleHandler(e){const{contractNode:t,contractName:n,nodePath:o,event:r,depth:s,afterTaskId:i}=e,c=t.getType();if(!c){console.warn(`Contract node type is not defined for: ${n}`);return}const d=this.registry.orderOf(c),u=t.get("/order"),p=m.isBigNumber(u)?u.toNumber():0,f=this.getNextTaskId()+i,g=r.seq;if(g===void 0)throw new Error("Event sequence missing");const T=Be(s,g,d,p,n,f);{const E=`${o}#${n}`,A=r.trace??[];if(r.source!=="external"&&A.includes(E))throw new Error(`Loop detected: repeated hop ${E} within the same event chain`)}const b=this.traceManager.addHop(r,o,n);this.queue.push({key:T,nodePath:o,contractName:n,contractNode:t,event:b})}shouldSkipForChannel(e,t){return e.source==="channel"&&!!e.originNodePath&&e.originNodePath!==t}}const je=(a,e,t)=>{(t instanceof _||t instanceof W)&&console.error(`[Blue] Failed to apply patches for contract "${a}" on event ${JSON.stringify(e)}`,t)};function F(a,e){const t=M(a),n=o=>{if(!N(o))return;const r=o.getContracts();(!(r!=null&&r.checkpoint)||!m.BlueNodeTypeSchema.isTypeOf(r.checkpoint,h.ChannelEventCheckpointSchema))&&o.addContract("checkpoint",e.jsonValueToNode({type:{name:"Channel Event Checkpoint",blueId:h.blueIds["Channel Event Checkpoint"]},lastEvents:{}}))};n(t);for(const{absPath:o}of D(t,e)){const r=t.get(o);N(r)&&n(r)}return B(t)}function xe(a,e){const t=M(a);return N(t)&&(te(t,e)||t.addContract("initialized",e.jsonValueToNode({type:{name:"Initialized Marker",blueId:h.blueIds["Initialized Marker"]}}))),B(t)}function te(a,e){const t=a.getContracts();return Object.values(t??{}).some(n=>e.isTypeOf(n,h.InitializedMarkerSchema,{checkSchemaExtensions:!0}))}class ne{constructor(e){l(this,"contractType","Channel Event Checkpoint");l(this,"contractBlueId",h.blueIds["Channel Event Checkpoint"]);l(this,"role","handler");this.cache=e}supports(e){var t,n;return e.source==="channel"&&((t=e.rootEvent)==null?void 0:t.payload)===e.payload&&((n=e.rootEvent)==null?void 0:n.source)==="external"}async getEventBlueId(e,t){var o;const n=(o=e.rootEvent)==null?void 0:o.payload;if(!n)throw new Error("Cannot calculate blueId for checkpoint: missing root event payload");if(n instanceof m.ResolvedBlueNode){const r=n.getMinimalNode();return await t.getBlue().calculateBlueId(r)}return await t.getBlue().calculateBlueId(n)}async handle(e,t,n){var s;if(!e.channelName||!((s=e.rootEvent)!=null&&s.seq))return;const o=await this.getEventBlueId(e,n),r=n.getNodePath().replace(/\/contracts\/checkpoint$/,"");this.cache.record(r,e,o)}}const X=(a,e)=>a.get(e)!==void 0;class Ve{constructor(){l(this,"firstSeen",new Map)}record(e,t,n){const o=e;this.firstSeen.has(o)||this.firstSeen.set(o,{docBase:e,event:t,eventBlueId:n})}flush(e){const t=[];for(const{docBase:n,event:o,eventBlueId:r}of this.firstSeen.values()){if(!o.channelName)continue;const s=S(n,"contracts/checkpoint/lastEvents",o.channelName),i=`${s}/blueId`;X(e,s)?t.push({op:X(e,i)?"replace":"add",path:i,val:r}):t.push({op:"add",path:s,val:{blueId:r}})}return t}clear(){this.firstSeen.clear()}}class oe{constructor(){l(this,"contractType","Composite Timeline Channel");l(this,"contractBlueId",h.blueIds["Composite Timeline Channel"]);l(this,"role","adapter")}supports(e,t,n){const o=n.getBlue().nodeToSchemaOutput(t,h.CompositeTimelineChannelSchema);return!o.channels||!e.channelName?!1:o.channels.includes(e.channelName)}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}class I{constructor(){l(this,"role","adapter")}baseSupports(e){return e.source!=="channel"}}class re extends I{constructor(){super(...arguments);l(this,"contractType","Document Update Channel");l(this,"contractBlueId",h.blueIds["Document Update Channel"])}supports(t,n,o){if(!this.baseSupports(t)||t.emissionType!=="update")return!1;const r=o.getBlue().nodeToSchemaOutput(n,h.DocumentUpdateChannelSchema),s=t.payload.get("/path");if(!s)return!1;const i=r.path;return v.isNonNullable(i)&&s===o.resolvePath(i)}handle(t,n,o,r){o.emitEvent({payload:t.payload,channelName:r,source:"channel"})}}class se extends I{constructor(){super(...arguments);l(this,"contractType","Embedded Node Channel");l(this,"contractBlueId",h.blueIds["Embedded Node Channel"])}supports(t,n,o){if(!this.baseSupports(t))return!1;const r=o.getBlue().nodeToSchemaOutput(n,h.EmbeddedNodeChannelSchema);return w(t.originNodePath)&&w(r.path)&&t.originNodePath===o.resolvePath(r.path)}handle(t,n,o,r){const s=o.getBlue().nodeToSchemaOutput(n,h.EmbeddedNodeChannelSchema),{originNodePath:i,payload:c}=t;w(s.path)&&i===o.resolvePath(s.path)&&o.emitEvent({payload:c,channelName:r,source:"channel"})}}class ae{constructor(){l(this,"contractType","Initialized Marker");l(this,"contractBlueId",h.blueIds["Initialized Marker"]);l(this,"role","marker")}supports(){return!1}handle(){}}class ie extends I{constructor(){super(...arguments);l(this,"contractType","Lifecycle Event Channel");l(this,"contractBlueId",h.blueIds["Lifecycle Event Channel"])}supports(t,n,o){return!this.baseSupports(t)||t.emissionType!=="lifecycle"||!this.isLifecycleEvent(t,o)?!1:this.isEventPatternMatch(t,n,o)}handle(t,n,o,r){o.emitEvent({payload:t.payload,channelName:r,source:"channel",emissionType:t.emissionType})}isLifecycleEvent(t,n){const o=n.getBlue(),r=t.payload;return o.isTypeOf(r,h.LifecycleEventSchema,{checkSchemaExtensions:!0})}isEventPatternMatch(t,n,o){var s;const r=(s=n.getProperties())==null?void 0:s.event;if(!r)return!0;try{const i=o.getBlue(),c=i.resolve(t.payload);return i.isTypeOfNode(c,r)}catch(i){return console.warn("Error during lifecycle event pattern matching:",i),!1}}}const Q=(a,e)=>{const t=e.getBlue();return t.isTypeOf(a.payload,h.TimelineEntrySchema)||t.isTypeOf(a.payload,C.MyOSTimelineEntrySchema)};class ce extends I{constructor(){super(...arguments);l(this,"contractType","MyOS Timeline Channel");l(this,"contractBlueId",C.blueIds["MyOS Timeline Channel"])}supports(t,n,o){var u;if(!this.baseSupports(t)||!Q(t,o))return!1;const s=o.getBlue().nodeToSchemaOutput(t.payload,C.MyOSTimelineEntrySchema),i=o.getBlue().nodeToSchemaOutput(n,C.MyOSTimelineChannelSchema),c=(u=s.timeline)==null?void 0:u.timelineId;return w(i.timelineId)&&w(c)&&c===i.timelineId}handle(t,n,o,r){Q(t,o)&&o.emitEvent({payload:t.payload,channelName:r,source:"channel"})}}class le extends I{constructor(){super(...arguments);l(this,"contractType","MyOS Agent Channel");l(this,"contractBlueId",C.blueIds["MyOS Agent Channel"])}supports(t,n,o){if(!this.baseSupports(t))return!1;try{const{myosAgentEvent:r,myosAgentChannel:s}=this.parseEventAndChannel(t,n,o);return this.isAgentMatch(r,s)&&this.isEventPatternMatch(r,s,o)}catch(r){return console.warn("Error in MyOSAgentChannelProcessor.supports:",r),!1}}handle(t,n,o,r){o.emitEvent({payload:t.payload,channelName:r,source:"channel"})}parseEventAndChannel(t,n,o){const r=o.getBlue(),s=r.nodeToSchemaOutput(t.payload,C.MyOSAgentEventSchema),i=r.nodeToSchemaOutput(n,C.MyOSAgentChannelSchema);return{myosAgentEvent:s,myosAgentChannel:i}}isAgentMatch(t,n){var s;const o=t.agentId,r=(s=n.agent)==null?void 0:s.agentId;return w(o)&&w(r)&&o===r}isEventPatternMatch(t,n,o){const r=n.event;if(!r)return!0;const s=t.event;if(!s)return!1;try{const i=o.getBlue(),c=i.nodeToJson(s),d=i.nodeToJson(r);return v.deepContains(c,d)}catch(i){return console.warn("Error during event pattern matching:",i),!1}}}class ue{constructor(){l(this,"contractType","Operation");l(this,"contractBlueId",h.blueIds.Operation);l(this,"role","adapter")}supports(e,t,n,o){const s=n.getBlue().nodeToSchemaOutput(t,h.OperationSchema),i=this.parseEventPayload(e,n),c=this.isOperationNameMatch(i,o),d=this.isOperationChannelMatch(e,s),u=this.isRequestPatternMatch(i,s,n);return c&&d&&u}async handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}parseEventPayload(e,t){const n=t.getBlue();if(n.isTypeOf(e.payload,h.TimelineEntrySchema,{checkSchemaExtensions:!0})){const o=n.nodeToSchemaOutput(e.payload,h.TimelineEntrySchema);if(o.message)return n.nodeToSchemaOutput(o.message,h.OperationRequestSchema)}return null}isOperationNameMatch(e,t){return w(e==null?void 0:e.operation)&&(e==null?void 0:e.operation)===t}isOperationChannelMatch(e,t){const n=t.channel;return v.isNullable(n)?!0:e.source==="channel"&&e.channelName===n}isRequestPatternMatch(e,t,n){const o=t.request;if(v.isNullable(o))return!0;const r=n.getBlue(),s=e==null?void 0:e.request;if(v.isNullable(s))return!1;const i=r.resolve(s);return r.isTypeOfNode(i,o)}}class de{constructor(){l(this,"contractType","Process Embedded");l(this,"role","adapter");l(this,"contractBlueId",h.blueIds["Process Embedded"])}supports(e){return e.source!=="channel"}handle(e,t,n){const o=n.getBlue().nodeToSchemaOutput(t,h.ProcessEmbeddedSchema);for(const r of o.paths??[])n.emitEvent({...e,dispatchPath:n.resolvePath(r)})}}const _e=!process.env.SKIP_ISOLATED_VM;let y=null;if(_e)try{y=require("isolated-vm")}catch{console.warn("isolated-vm not available, using fallback evaluation method")}function We(a){return/\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(a)||/\bexport\s+/.test(a)}class ${static getIvmUnavailableMessage(){const e=typeof process<"u"&&process.version?process.version:"unknown",t=typeof process<"u"&&process.platform?process.platform:"unknown",n=typeof process<"u"&&process.arch?process.arch:"unknown";return["isolated-vm is required for expression evaluation but could not be loaded.","This feature only works in a Node.js environment with the native addon available.","",`Detected environment: Node ${e} on ${t}/${n}.`,"","Common causes:","- Running in a non-Node environment (browser, edge/runtime without Node).","- 'isolated-vm' is not installed, or failed to build its native addon.","- The module was bundled/stripped by a build tool.","","How to fix:","- Ensure 'isolated-vm' is listed in dependencies (not devDependencies) of the executing package.","- Reinstall or rebuild: npm ci && npm rebuild isolated-vm (or equivalent with your package manager).","- Run this code on a supported Node.js runtime (not browser/edge workers)."].join(`
2
- `)}static async ensureIvm(){if(y)return y;try{typeof require=="function"?y=require("isolated-vm"):y=(await import("isolated-vm")).default??await import("isolated-vm")}catch(e){console.error(e),y=null}return y}static async evaluate({code:e,ctx:t,bindings:n={},options:o={}}){if(await this.ensureIvm(),!y)throw new Error(this.getIvmUnavailableMessage());return this.evaluateSecure(e,n,t,o)}static async evaluateSecure(e,t,n,o={}){if(!y)throw new Error(this.getIvmUnavailableMessage());const r=new y.Isolate({memoryLimit:32}),s=await r.createContext(),i=s.global;try{await this.setupIsolateEnvironment(i,t);const c=new Map,d=this.createModuleResolver(r,s,c,n);let u;return We(e)?u=await this.evaluateESModule(r,s,e,o,d):u=await this.evaluateSimpleScript(r,s,e,t,o),this.deepClone(u)}catch(c){throw o.isCodeBlock?new ee(e,c):new Z(e,c)}finally{s.release(),r.dispose()}}static async setupIsolateEnvironment(e,t){if(!y)throw new Error("isolated-vm not available");const n=new y.Callback((...r)=>console.log(...r)),o=new y.ExternalCopy({log:n}).copyInto();await e.set("console",o);for(const[r,s]of Object.entries(t))typeof s=="function"?await e.set(r,new y.Callback(s)):await e.set(r,new y.ExternalCopy(s).copyInto())}static createModuleResolver(e,t,n,o){return async r=>{if(n.has(r))return n.get(r);if(r.startsWith("blue:")){const s=r.slice(5),i=o.loadBlueContent;if(typeof i!="function")throw new Error(`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`);const c=await i(s),d=await e.compileModule(c);return n.set(r,d),await d.instantiate(t,this.createModuleResolver(e,t,n,o)),d}if(/^https?:\/\//.test(r)){let s;if(typeof o.loadExternalModule=="function")s=await o.loadExternalModule(r);else throw new Error(`ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${r})`);const i=await e.compileModule(s);return n.set(r,i),await i.instantiate(t,this.createModuleResolver(e,t,n,o)),i}throw new Error(`Unsupported module specifier "${r}"`)}}static async evaluateSimpleScript(e,t,n,o,r){const s=Object.keys(o).join(", "),i=Object.keys(o).map(u=>u),c=`(async (${s}) => { ${r.isCodeBlock?n:`return (${n});`} })(${i.join(", ")})`;return await(await e.compileScript(c)).run(t,{timeout:r.timeout??500,promise:!0,copy:!0,release:!0})}static async evaluateESModule(e,t,n,o,r){let s=n;if(o.isCodeBlock){const d=/^\s*(import\s.+?;|export\s.+?;)/gm,u=(n.match(d)||[]).join(`
3
- `),p=n.replace(d,"").trim();s=`
1
+ "use strict";var Ee=Object.create;var R=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Pe=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of we(e))!Te.call(a,o)&&o!==t&&R(a,o,{get:()=>e[o],enumerable:!(n=ve(e,o))||n.enumerable});return a};var W=(a,e,t)=>(t=a!=null?Ee(be(a)):{},Pe(e||!a||!a.__esModule?R(t,"default",{value:a,enumerable:!0}):t,a));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@blue-repository/core-dev"),p=require("@blue-labs/language"),E=require("@blue-labs/shared-utils"),S=require("@blue-repository/myos-dev"),P=(...a)=>a.map((e,t)=>{if(typeof e!="string")return"";if(t===0&&e==="/")return"/";const n=t>0?e.replace(/^\/+/,""):e;return t<a.length-1?n.replace(/\/+$/,""):n}).filter(Boolean).join("/").replace(/\/{2,}/g,"/");class Q{constructor(e,t,n,o){this.getDocument=e,this.taskInfo=t,this.blue=n,this.onFlush=o}actions=[];get(e){const t=this.getDocument(),n=P(this.taskInfo.nodePath,e);return t.get(n)}addPatch(e){this.actions.push({kind:"patch",patch:{...e,path:P(this.taskInfo.nodePath,e.path)}})}emitEvent(e){const t=this.taskInfo.event,n=t.trace??[],o={...e,source:e.source??"internal",originNodePath:e.originNodePath??this.taskInfo.nodePath,rootEvent:e.rootEvent??t.rootEvent??t,trace:[...n],emissionType:e.emissionType??t.emissionType};this.actions.push({kind:"event",event:o})}async flush(){if(!this.actions.length)return[];const e=[...this.actions];return this.actions.length=0,await this.onFlush?.(e),e}getNodePath(){return this.taskInfo.nodePath}resolvePath(e){return P(this.taskInfo.nodePath,e)}getTaskInfo(){return this.taskInfo}getBlue(){return this.blue}loadExternalModule(){throw new Error("Not implemented")}loadBlueContent(e){const t=this.blue.getNodeProvider().fetchFirstByBlueId(e);if(!t)throw new Error(`Blue node not found for blueId: ${e}`);return Promise.resolve(JSON.stringify(this.blue.nodeToJson(t)))}}class A extends Error{constructor(e,t){super(`Cannot apply patch ${JSON.stringify(e)}`),this.patch=e,this.cause=t,this.name="PatchApplicationError"}}class j extends Error{constructor(e,t,n){super(`Patch ${JSON.stringify(e)} touches "${e.op==="move"||e.op==="copy"?`${e.from} → ${e.path}`:e.path}" which is inside embedded document "${t}" (Process Embedded @ "${n}")`),this.patch=e,this.offendingPath=t,this.contractNodePath=n,this.name="EmbeddedDocumentModificationError"}}class G extends Error{constructor(e,t){super(`Failed to evaluate expression "${e}"`),this.code=e,this.cause=t,this.name="ExpressionEvaluationError"}}class K extends Error{constructor(e,t){super(`Failed to evaluate code block "${e}"`),this.code=e,this.cause=t,this.name="CodeBlockEvaluationError"}}function I(a){return E.deepFreeze(a)}function k(a){return a.clone()}function $(a,e,t="/",n=[]){const o=a.getContracts()??{};for(const[r,s]of Object.entries(o))if(e.isTypeOf(s,l.ProcessEmbeddedSchema)){const d=e.nodeToSchemaOutput(s,l.ProcessEmbeddedSchema).paths??[];for(const u of d)n.push({absPath:P(t,u),contractPath:P(t,`contracts/${r}`)})}for(const[r,s]of Object.entries(a.getProperties()??{}))$(s,e,P(t,r),n);return n}function J(a,e){return a===e||a.startsWith(e.endsWith("/")?e:e+"/")}function U(a,e){if(!e.length)return a;let t=k(a);for(const n of e)try{t=p.applyBlueNodePatch(t,n,!0)}catch(o){throw new A(n,o)}return I(t)}function v(a){return a!=null}function C(a){return a instanceof p.BlueNode}class Se{data;length;compare;constructor(e=[],t=(n,o)=>n<o?-1:n>o?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,o=t[e];for(;e>0;){const r=e-1>>1,s=t[r];if(n(o,s)>=0)break;t[e]=s,e=r}t[e]=o}_down(e){const{data:t,compare:n}=this,o=this.length>>1,r=t[e];for(;e<o;){let s=(e<<1)+1;const i=s+1;if(i<this.length&&n(t[i],t[s])<0&&(s=i),n(t[s],r)>=0)break;t[e]=t[s],e=s}t[e]=r}}const Ce=(a,e,t,n,o,r)=>[-a,e,t,n,o,r],Ne=(a,e)=>{for(let t=0;t<a.key.length;t++){const n=a.key[t],o=e.key[t];if(n!==o)return typeof n=="number"&&typeof o=="number"?n-o:typeof n=="string"&&typeof o=="string"?n.localeCompare(o):0}return 0};class Ie{queue;constructor(){this.queue=new Se([],Ne)}push(e){this.queue.push(e)}pop(){return this.queue.pop()}get length(){return this.queue.length}}class ke{processors=new Map;typeOrder=new Map;constructor(e=[]){e.forEach((t,n)=>this.register(t,n))}register(e,t){if(this.processors.has(e.contractBlueId))throw new Error(`Processor for ${e.contractType} already registered`);this.processors.set(e.contractBlueId,e),this.typeOrder.has(e.contractBlueId)||this.typeOrder.set(e.contractBlueId,t??this.typeOrder.size)}get(e){if(!e)return;const t=e.getBlueId();if(t)return this.processors.get(t)}orderOf(e){if(!e)return 0;const t=e.getBlueId();return t?this.typeOrder.get(t)??0:0}values(){return this.processors.values()}}class M{isEnabled;static MAX_TRACE_LENGTH=128;constructor(){this.isEnabled=process.env.TRACE_BLUE_ENABLED!=="false"}makeHop(e,t){return`${e}#${t}`}shouldTrace(){return this.isEnabled}addHop(e,t,n){if(!this.shouldTrace())return{...e};const o=e.trace??[],s=[...o.length>=M.MAX_TRACE_LENGTH?o.slice(o.length-(M.MAX_TRACE_LENGTH-1)):o,this.makeHop(t,n)];return{...e,trace:s}}getTrace(e){return e.trace??[]}clearTrace(e){return{...e,trace:[]}}isTracingEnabled(){return this.isEnabled}}function Be(a){return Object.entries(a.getContracts()??{})}const Oe=64;class Me{constructor(e,t,n,o,r){this.blue=e,this.registry=t,this.queue=n,this.getNextTaskId=o,this.getNextEventSeq=r,this.traceManager=new M}traceManager;async route(e,t,n,o,r=0){if(n.seq===void 0&&(n.seq=this.getNextEventSeq()),t.length===0){if(n.dispatchPath){const c=n.dispatchPath.split("/").filter(Boolean),d={...n};return delete d.dispatchPath,this.route(e,c,d,o,r)}if(n.source==="channel"&&n.originNodePath&&n.originNodePath!=="/"){const c=n.originNodePath?.split("/").filter(Boolean)??[];return this.route(e,c,n,o,r)}}const s=P("/",t.join("/")),i=e.get(s);C(i)&&await this.traverseContracts({doc:e,node:i,nodePath:s,event:n,afterTaskId:o,pathSegments:t,inlineDepth:r})}async traverseContracts(e){const{doc:t,node:n,nodePath:o,event:r,afterTaskId:s,pathSegments:i,inlineDepth:c}=e;if(!this.shouldSkipForChannel(r,o))for(const[d,u]of Be(n)){if(!u.getType())continue;const h=this.registry.get(u.getType());if(!h){console.warn(`No processor registered for contract: ${d}`);continue}const y={nodePath:o,contractName:d,contractNode:u,event:r},f=new Q(()=>t,y,this.blue);if(h.supports(r,u,f,d))switch(h.role){case"adapter":await this.processAdapter({cp:h,event:r,contractNode:u,ctx:f,contractName:d,doc:t,afterTaskId:s,inlineDepth:c});break;case"handler":this.scheduleHandler({contractNode:u,contractName:d,nodePath:o,event:r,depth:i.length,afterTaskId:s});break}}}async processAdapter(e){const{cp:t,event:n,contractNode:o,ctx:r,contractName:s,doc:i,afterTaskId:c,inlineDepth:d}=e;if(d>=Oe)throw new Error("Adapter recursion limit reached");const u=this.traceManager.addHop(n,r.getTaskInfo()?.nodePath??"",s);await t.handle(u,o,r,s);const h=await r.flush();if(h.find(w=>w.kind==="patch"))throw new Error(`Contract "${s}" (adapter) attempted to patch the document`);const f=h.filter(w=>w.kind==="event");for(const w of f)await this.route(i,[],w.event,c,d+1)}scheduleHandler(e){const{contractNode:t,contractName:n,nodePath:o,event:r,depth:s,afterTaskId:i}=e,c=t.getType();if(!c){console.warn(`Contract node type is not defined for: ${n}`);return}const d=this.registry.orderOf(c),u=t.get("/order"),h=p.isBigNumber(u)?u.toNumber():0,y=this.getNextTaskId()+i,f=r.seq;if(f===void 0)throw new Error("Event sequence missing");const w=Ce(s,f,d,h,n,y);{const B=`${o}#${n}`,b=r.trace??[];if(r.source!=="external"&&b.includes(B))throw new Error(`Loop detected: repeated hop ${B} within the same event chain`)}const g=this.traceManager.addHop(r,o,n);this.queue.push({key:w,nodePath:o,contractName:n,contractNode:t,event:g})}shouldSkipForChannel(e,t){return e.source==="channel"&&!!e.originNodePath&&e.originNodePath!==t}}const qe=(a,e,t)=>{(t instanceof A||t instanceof j)&&console.error(`[Blue] Failed to apply patches for contract "${a}" on event ${JSON.stringify(e)}`,t)};function L(a,e){const t=k(a),n=o=>{if(!C(o))return;const r=o.getContracts();(!r?.checkpoint||!p.BlueNodeTypeSchema.isTypeOf(r.checkpoint,l.ChannelEventCheckpointSchema))&&o.addContract("checkpoint",e.jsonValueToNode({type:{name:"Channel Event Checkpoint",blueId:l.blueIds["Channel Event Checkpoint"]},lastEvents:{}}))};n(t);for(const{absPath:o}of $(t,e)){const r=t.get(o);C(r)&&n(r)}return I(t)}function $e(a,e){const t=k(a);return C(t)&&(Y(t,e)||t.addContract("initialized",e.jsonValueToNode({type:{name:"Initialized Marker",blueId:l.blueIds["Initialized Marker"]}}))),I(t)}function Y(a,e){const t=a.getContracts();return Object.values(t??{}).some(n=>e.isTypeOf(n,l.InitializedMarkerSchema,{checkSchemaExtensions:!0}))}class Z{constructor(e){this.cache=e}contractType="Channel Event Checkpoint";contractBlueId=l.blueIds["Channel Event Checkpoint"];role="handler";supports(e){return e.source==="channel"&&e.rootEvent?.payload===e.payload&&e.rootEvent?.source==="external"}async getEventBlueId(e,t){const n=e.rootEvent?.payload;if(!n)throw new Error("Cannot calculate blueId for checkpoint: missing root event payload");if(n instanceof p.ResolvedBlueNode){const o=n.getMinimalNode();return await t.getBlue().calculateBlueId(o)}return await t.getBlue().calculateBlueId(n)}async handle(e,t,n){if(!e.channelName||!e.rootEvent?.seq)return;const o=await this.getEventBlueId(e,n),r=n.getNodePath().replace(/\/contracts\/checkpoint$/,"");this.cache.record(r,e,o)}}const z=(a,e)=>a.get(e)!==void 0;class De{firstSeen=new Map;record(e,t,n){const o=e;this.firstSeen.has(o)||this.firstSeen.set(o,{docBase:e,event:t,eventBlueId:n})}flush(e){const t=[];for(const{docBase:n,event:o,eventBlueId:r}of this.firstSeen.values()){if(!o.channelName)continue;const s=P(n,"contracts/checkpoint/lastEvents",o.channelName),i=`${s}/blueId`;z(e,s)?t.push({op:z(e,i)?"replace":"add",path:i,val:r}):t.push({op:"add",path:s,val:{blueId:r}})}return t}clear(){this.firstSeen.clear()}}class ee{contractType="Composite Timeline Channel";contractBlueId=l.blueIds["Composite Timeline Channel"];role="adapter";supports(e,t,n){const o=n.getBlue().nodeToSchemaOutput(t,l.CompositeTimelineChannelSchema);return!o.channels||!e.channelName?!1:o.channels.includes(e.channelName)}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}class N{role="adapter";baseSupports(e){return e.source!=="channel"}}class te extends N{contractType="Document Update Channel";contractBlueId=l.blueIds["Document Update Channel"];supports(e,t,n){if(!this.baseSupports(e)||e.emissionType!=="update")return!1;const o=n.getBlue().nodeToSchemaOutput(t,l.DocumentUpdateChannelSchema),r=e.payload.get("/path");if(!r)return!1;const s=o.path;return E.isNonNullable(s)&&r===n.resolvePath(s)}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}class ne extends N{contractType="Embedded Node Channel";contractBlueId=l.blueIds["Embedded Node Channel"];supports(e,t,n){if(!this.baseSupports(e))return!1;const o=n.getBlue().nodeToSchemaOutput(t,l.EmbeddedNodeChannelSchema);return v(e.originNodePath)&&v(o.path)&&e.originNodePath===n.resolvePath(o.path)}handle(e,t,n,o){const r=n.getBlue().nodeToSchemaOutput(t,l.EmbeddedNodeChannelSchema),{originNodePath:s,payload:i}=e;v(r.path)&&s===n.resolvePath(r.path)&&n.emitEvent({payload:i,channelName:o,source:"channel"})}}class oe{contractType="Initialized Marker";contractBlueId=l.blueIds["Initialized Marker"];role="marker";supports(){return!1}handle(){}}class re extends N{contractType="Lifecycle Event Channel";contractBlueId=l.blueIds["Lifecycle Event Channel"];supports(e,t,n){return!this.baseSupports(e)||e.emissionType!=="lifecycle"||!this.isLifecycleEvent(e,n)?!1:this.isEventPatternMatch(e,t,n)}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel",emissionType:e.emissionType})}isLifecycleEvent(e,t){const n=t.getBlue(),o=e.payload;return n.isTypeOf(o,l.LifecycleEventSchema,{checkSchemaExtensions:!0})}isEventPatternMatch(e,t,n){const o=t.getProperties()?.event;if(!o)return!0;try{const r=n.getBlue(),s=r.resolve(e.payload);return r.isTypeOfNode(s,o)}catch(r){return console.warn("Error during lifecycle event pattern matching:",r),!1}}}const H=(a,e)=>{const t=e.getBlue();return t.isTypeOf(a.payload,l.TimelineEntrySchema)||t.isTypeOf(a.payload,S.MyOSTimelineEntrySchema)};class se extends N{contractType="MyOS Timeline Channel";contractBlueId=S.blueIds["MyOS Timeline Channel"];supports(e,t,n){if(!this.baseSupports(e)||!H(e,n))return!1;const r=n.getBlue().nodeToSchemaOutput(e.payload,S.MyOSTimelineEntrySchema),s=n.getBlue().nodeToSchemaOutput(t,S.MyOSTimelineChannelSchema),i=r.timeline?.timelineId;return v(s.timelineId)&&v(i)&&i===s.timelineId}handle(e,t,n,o){H(e,n)&&n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}class ae extends N{contractType="MyOS Agent Channel";contractBlueId=S.blueIds["MyOS Agent Channel"];supports(e,t,n){if(!this.baseSupports(e))return!1;try{const{myosAgentEvent:o,myosAgentChannel:r}=this.parseEventAndChannel(e,t,n);return this.isAgentMatch(o,r)&&this.isEventPatternMatch(o,r,n)}catch(o){return console.warn("Error in MyOSAgentChannelProcessor.supports:",o),!1}}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}parseEventAndChannel(e,t,n){const o=n.getBlue(),r=o.nodeToSchemaOutput(e.payload,S.MyOSAgentEventSchema),s=o.nodeToSchemaOutput(t,S.MyOSAgentChannelSchema);return{myosAgentEvent:r,myosAgentChannel:s}}isAgentMatch(e,t){const n=e.agentId,o=t.agent?.agentId;return v(n)&&v(o)&&n===o}isEventPatternMatch(e,t,n){const o=t.event;if(!o)return!0;const r=e.event;if(!r)return!1;try{const s=n.getBlue(),i=s.nodeToJson(r),c=s.nodeToJson(o);return E.deepContains(i,c)}catch(s){return console.warn("Error during event pattern matching:",s),!1}}}class ie{contractType="Operation";contractBlueId=l.blueIds.Operation;role="adapter";supports(e,t,n,o){const s=n.getBlue().nodeToSchemaOutput(t,l.OperationSchema),i=this.parseEventPayload(e,n),c=this.isOperationNameMatch(i,o),d=this.isOperationChannelMatch(e,s),u=this.isRequestPatternMatch(i,s,n);return c&&d&&u}async handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}parseEventPayload(e,t){const n=t.getBlue();if(n.isTypeOf(e.payload,l.TimelineEntrySchema,{checkSchemaExtensions:!0})){const o=n.nodeToSchemaOutput(e.payload,l.TimelineEntrySchema);if(o.message)return n.nodeToSchemaOutput(o.message,l.OperationRequestSchema)}return null}isOperationNameMatch(e,t){return v(e?.operation)&&e?.operation===t}isOperationChannelMatch(e,t){const n=t.channel;return E.isNullable(n)?!0:e.source==="channel"&&e.channelName===n}isRequestPatternMatch(e,t,n){const o=t.request;if(E.isNullable(o))return!0;const r=n.getBlue(),s=e?.request;if(E.isNullable(s))return!1;const i=r.resolve(s);return r.isTypeOfNode(i,o)}}class ce{contractType="Process Embedded";role="adapter";contractBlueId=l.blueIds["Process Embedded"];supports(e){return e.source!=="channel"}handle(e,t,n){const o=n.getBlue().nodeToSchemaOutput(t,l.ProcessEmbeddedSchema);for(const r of o.paths??[])n.emitEvent({...e,dispatchPath:n.resolvePath(r)})}}const Ae=!process.env.SKIP_ISOLATED_VM;let m=null;if(Ae)try{m=require("isolated-vm")}catch{console.warn("isolated-vm not available, using fallback evaluation method")}function je(a){return/\bimport\s.+\sfrom\s+['"][^'"]+['"]/.test(a)||/\bexport\s+/.test(a)}class q{static getIvmUnavailableMessage(){const e=typeof process<"u"&&process.version?process.version:"unknown",t=typeof process<"u"&&process.platform?process.platform:"unknown",n=typeof process<"u"&&process.arch?process.arch:"unknown";return["isolated-vm is required for expression evaluation but could not be loaded.","This feature only works in a Node.js environment with the native addon available.","",`Detected environment: Node ${e} on ${t}/${n}.`,"","Common causes:","- Running in a non-Node environment (browser, edge/runtime without Node).","- 'isolated-vm' is not installed, or failed to build its native addon.","- The module was bundled/stripped by a build tool.","","How to fix:","- Ensure 'isolated-vm' is listed in dependencies (not devDependencies) of the executing package.","- Reinstall or rebuild: npm ci && npm rebuild isolated-vm (or equivalent with your package manager).","- Run this code on a supported Node.js runtime (not browser/edge workers)."].join(`
2
+ `)}static async ensureIvm(){if(m)return m;try{typeof require=="function"?m=require("isolated-vm"):m=(await import("isolated-vm")).default??await import("isolated-vm")}catch(e){console.error(e),m=null}return m}static async evaluate({code:e,ctx:t,bindings:n={},options:o={}}){if(await this.ensureIvm(),!m)throw new Error(this.getIvmUnavailableMessage());return this.evaluateSecure(e,n,t,o)}static async evaluateSecure(e,t,n,o={}){if(!m)throw new Error(this.getIvmUnavailableMessage());const r=new m.Isolate({memoryLimit:32}),s=await r.createContext(),i=s.global;try{await this.setupIsolateEnvironment(i,t);const c=new Map,d=this.createModuleResolver(r,s,c,n);let u;return je(e)?u=await this.evaluateESModule(r,s,e,o,d):u=await this.evaluateSimpleScript(r,s,e,t,o),this.deepClone(u)}catch(c){throw o.isCodeBlock?new K(e,c):new G(e,c)}finally{s.release(),r.dispose()}}static async setupIsolateEnvironment(e,t){if(!m)throw new Error("isolated-vm not available");const n=new m.Callback((...r)=>console.log(...r)),o=new m.ExternalCopy({log:n}).copyInto();await e.set("console",o);for(const[r,s]of Object.entries(t))typeof s=="function"?await e.set(r,new m.Callback(s)):await e.set(r,new m.ExternalCopy(s).copyInto())}static createModuleResolver(e,t,n,o){return async r=>{if(n.has(r))return n.get(r);if(r.startsWith("blue:")){const s=r.slice(5),i=o.loadBlueContent;if(typeof i!="function")throw new Error(`ProcessingContext is missing a loadBlueContent(blueId) implementation (needed for ${r})`);const c=await i(s),d=await e.compileModule(c);return n.set(r,d),await d.instantiate(t,this.createModuleResolver(e,t,n,o)),d}if(/^https?:\/\//.test(r)){let s;if(typeof o.loadExternalModule=="function")s=await o.loadExternalModule(r);else throw new Error(`ProcessingContext is missing a loadExternalModule(url) implementation (needed for ${r})`);const i=await e.compileModule(s);return n.set(r,i),await i.instantiate(t,this.createModuleResolver(e,t,n,o)),i}throw new Error(`Unsupported module specifier "${r}"`)}}static async evaluateSimpleScript(e,t,n,o,r){const s=Object.keys(o).join(", "),i=Object.keys(o).map(u=>u),c=`(async (${s}) => { ${r.isCodeBlock?n:`return (${n});`} })(${i.join(", ")})`;return await(await e.compileScript(c)).run(t,{timeout:r.timeout??500,promise:!0,copy:!0,release:!0})}static async evaluateESModule(e,t,n,o,r){let s=n;if(o.isCodeBlock){const d=/^\s*(import\s.+?;|export\s.+?;)/gm,u=(n.match(d)||[]).join(`
3
+ `),h=n.replace(d,"").trim();s=`
4
4
  ${u}
5
5
  const run = function() {
6
- ${p}
6
+ ${h}
7
7
  };
8
8
  export default run();
9
- `}const i=await e.compileModule(s);return await i.instantiate(t,r),await i.evaluate({timeout:o.timeout??500,promise:!0,reference:!0,release:!0}),await i.namespace.get("default",{timeout:o.timeout??500,promise:!0,copy:!0,release:!0})}static deepClone(e){return typeof e>"u"?e:JSON.parse(JSON.stringify(e))}}class J{static createStandardBindings(e,t,n){const o=e.getBlue(),r=o.nodeToJson(t.payload,"simple"),s=m.isBigNumber(r)?r.toNumber():r;return{document:i=>{const c=e.get(i);return m.isBigNumber(c)?c.toNumber():N(c)?o.nodeToJson(c,"original"):c},event:s,steps:n}}}const Je=/^\$\{([\s\S]*)\}$/,Ue=/\$\{([\s\S]*?)\}/,P=a=>typeof a!="string"?!1:Je.test(a),V=a=>typeof a!="string"?!1:Ue.test(a),he=a=>{if(!P(a))throw new Error(`Invalid expression: ${a}`);return a.slice(2,-1)};class q{static createBindings(e,t,n){return J.createStandardBindings(e,t,n)}static async evaluate(e,t,n,o){const{coerceToString:r}=o;if(P(e)){const s=he(e),i=await $.evaluate({code:s,ctx:t,bindings:n});return r?String(i??""):i}if(V(e)){const i=`\`${String(e).replace(/`/g,"\\`")}\``,c=await $.evaluate({code:i,ctx:t,bindings:n});return String(c??"")}return r?String(e):e}}function G(a,e){const{op:t,path:n,val:o,from:r}=a;if((t==="move"||t==="copy")&&!r)throw new Error(`${t} operation requires 'from' path`);if((t==="add"||t==="replace")&&o===void 0)throw new Error(`${t} operation requires 'val' property`);const s={type:"Document Update",op:t,path:n};return o!==void 0&&(s.val=o),r!==void 0&&(s.from=r),e.jsonValueToNode(s)}function Le(a){return a.jsonValueToNode({type:"Document Processing Initiated"})}class ze{constructor(){l(this,"stepType","Update Document")}supports(e){return m.BlueNodeTypeSchema.isTypeOf(e,h.UpdateDocumentSchema)}async execute(e,t,n,o,r){const s=n.getBlue();if(!m.BlueNodeTypeSchema.isTypeOf(e,h.UpdateDocumentSchema))return;const i=await this.evaluateChangeset(e.get("/changeset"),n,t,r),c=m.applyBlueNodePatch(e,{op:"replace",path:"/changeset",val:i}),d=n.getBlue().nodeToSchemaOutput(c,h.UpdateDocumentSchema);for(const u of d.changeset??[]){if(!u.path)continue;const p=await this.evaluateChangePath(u.path,n,t,r),f=u.val;if((u.op==="replace"||u.op==="add")&&v.isNonNullable(f)){const g=await this.evaluateChangeValue(f,n,t,r);n.addPatch({op:u.op,path:p,val:g}),n.emitEvent({payload:G({op:u.op,path:n.resolvePath(p),val:s.nodeToJson(g,"original")},s),emissionType:"update"})}u.op==="remove"&&(n.addPatch({op:u.op,path:p}),n.emitEvent({payload:G({op:u.op,path:n.resolvePath(p),val:null},s),emissionType:"update"}))}}async evaluateChangeset(e,t,n,o){const r=t.getBlue();if(P(e)){const s=he(e),i=await $.evaluate({code:s,ctx:t,bindings:J.createStandardBindings(t,n,o)});return r.jsonValueToNode(i??null)}if(N(e))return e;throw new Error("Invalid changeset: expected a string or document node")}async evaluateChangeValue(e,t,n,o){const r=e.getValue(),s=t.getBlue();if(P(r)||typeof r=="string"&&V(r)){const i=q.createBindings(t,n,o),c=await q.evaluate(String(r),t,i,{coerceToString:!P(r)});return s.jsonValueToNode(c??null)}return e}async evaluateChangePath(e,t,n,o){const r=q.createBindings(t,n,o);if(P(e)||V(e)){const s=await q.evaluate(e,t,r,{coerceToString:!0});return String(s??"")}return e}}class Re{constructor(){l(this,"stepType","Trigger Event")}supports(e){return m.BlueNodeTypeSchema.isTypeOf(e,h.TriggerEventSchema)}async execute(e,t,n){const o=n.getBlue();if(!m.BlueNodeTypeSchema.isTypeOf(e,h.TriggerEventSchema))return;const r=o.nodeToSchemaOutput(e,h.TriggerEventSchema);r.event&&n.emitEvent({payload:r.event,emissionType:"triggered"})}}class He{constructor(){l(this,"stepType","JavaScript Code")}supports(e){return m.BlueNodeTypeSchema.isTypeOf(e,h.JavaScriptCodeSchema)}async execute(e,t,n,o,r){if(!m.BlueNodeTypeSchema.isTypeOf(e,h.JavaScriptCodeSchema))return;const s=n.getBlue(),i=s.nodeToSchemaOutput(e,h.JavaScriptCodeSchema);if(!i.code)throw new Error("JavaScript code is required");const c=await $.evaluate({code:i.code,ctx:n,bindings:J.createStandardBindings(n,t,r),options:{isCodeBlock:!0,timeout:500}});if(c&&typeof c=="object"&&"events"in c){const d=c;if(Array.isArray(d.events))for(const u of d.events)n.emitEvent({payload:s.jsonValueToNode(u),emissionType:"triggered"})}return c}}const Fe=[new ze,new Re,new He];class U{constructor(e=Fe){l(this,"contractType","Sequential Workflow");l(this,"contractBlueId",h.blueIds["Sequential Workflow"]);l(this,"role","handler");l(this,"executors",[]);this.executors=e}registerExecutor(e){this.executors.push(e)}supports(e,t,n){const r=n.getBlue().nodeToSchemaOutput(t,h.SequentialWorkflowSchema),s=this.isChannelNameMatch(e,r),i=this.isEventPatternMatch(e,t,n);return s&&i}async handle(e,t,n,o){var i;const r={},s=(i=t.getProperties())==null?void 0:i.steps.getItems();for(const[c,d]of(s??[]).entries()){const u=this.executors.find(f=>f.supports(d));if(!u)throw new Error(`Unsupported workflow step type "${d.getType()}"`);const p=await u.execute(d,e,n,o,r);if(p!==void 0){const f=d.getName(),g=typeof f=="string"?f:`Step${c+1}`;r[g]=p}await n.flush()}}isChannelNameMatch(e,t){const n=t.channel;return v.isNonNullable(n)&&e.source==="channel"&&e.channelName===n}isEventPatternMatch(e,t,n){var r;const o=(r=t.getProperties())==null?void 0:r.event;if(!o)return!0;try{const s=n.getBlue(),i=s.resolve(e.payload);return s.isTypeOfNode(i,o)}catch(s){return console.warn("Error during event pattern matching:",s),!1}}}class pe{constructor(e){l(this,"contractType","Sequential Workflow Operation");l(this,"contractBlueId",h.blueIds["Sequential Workflow Operation"]);l(this,"role","handler");l(this,"sequentialWorkflowProcessor");this.sequentialWorkflowProcessor=e||new U}supports(e,t,n){const s=n.getBlue().nodeToSchemaOutput(t,h.SequentialWorkflowOperationSchema).operation,i=e.channelName;return e.source==="channel"&&v.isNonNullable(i)&&v.isNonNullable(s)&&i===s}async handle(e,t,n,o){try{await this.sequentialWorkflowProcessor.handle(e,t,n,o)}catch(r){throw console.error("Error in SequentialWorkflowOperationProcessor.handle:",r),r}}}const K=a=>m.BlueNodeTypeSchema.isTypeOf(a.payload,h.TimelineEntrySchema);class me extends I{constructor(){super(...arguments);l(this,"contractType","Timeline Channel");l(this,"contractBlueId",h.blueIds["Timeline Channel"])}supports(t,n,o){var u;if(!this.baseSupports(t)||!K(t))return!1;const s=o.getBlue().nodeToSchemaOutput(t.payload,h.TimelineEntrySchema),i=o.getBlue().nodeToSchemaOutput(n,h.TimelineChannelSchema),c=(u=s.timeline)==null?void 0:u.timelineId;return w(i.timelineId)&&w(c)&&c===i.timelineId}handle(t,n,o,r){K(t)&&o.emitEvent({payload:t.payload,channelName:r,source:"channel"})}}class fe extends I{constructor(){super(...arguments);l(this,"contractType","Triggered Event Channel");l(this,"contractBlueId",h.blueIds["Triggered Event Channel"])}supports(t){return this.baseSupports(t)?t.emissionType==="triggered":!1}handle(t,n,o,r){o.emitEvent({payload:t.payload,channelName:r,source:"channel"})}}const Xe=[new de,new se,new re,new me,new ce,new le,new oe,new ie,new fe,new ue,new U,new pe,new ae];class Qe{constructor(e,t=Xe){l(this,"taskCounter",0);l(this,"eventCounter",0);l(this,"registry");l(this,"queue");l(this,"router");l(this,"checkpointCache",new Ve);this.blue=e,this.registry=new qe(t),this.queue=new Me,this.router=new Ae(this.blue,this.registry,this.queue,()=>++this.taskCounter,()=>++this.eventCounter),this.register(new ne(this.checkpointCache),9999)}register(e,t){this.registry.register(e,t)}async initialize(e){let t=F(B(e),this.blue);const n={payload:Le(this.blue),source:"internal",emissionType:"lifecycle"},o=[n.payload];await this.router.route(t,[],n,0);const r=await this.drainQueue(t);return t=r.state,o.push(...r.emitted),t=xe(t,this.blue),{state:M(t),emitted:o}}async processEvents(e,t){let n=F(B(e),this.blue);const o=[];if(!te(n,this.blue))throw new Error("Document is not initialized");for(const r of t)try{const s={payload:r,source:"external"};await this.router.route(n,[],s,0);const i=await this.drainQueue(n);n=i.state,o.push(...i.emitted);const c=this.checkpointCache.flush(n);c.length&&(n=H(n,c))}finally{this.checkpointCache.clear()}return{state:M(n),emitted:o}}async drainQueue(e){var s;let t=e;const n=[],o=1e4;let r=0;for(;this.queue.length;){if(++r>o)throw new Error("Possible cycle – too many iterations");const i=this.queue.pop(),{nodePath:c,contractName:d,contractNode:u,event:p}=i,f=t.get(c);if(!N(f)||!((s=f.getContracts())!=null&&s[d])||!u.getType())continue;const g=this.registry.get(u.getType());if(!g){console.warn(`No processor registered for contract: ${d}`);continue}const T=new Y(()=>t,i,this.blue,async b=>{for(const E of b)if(E.kind==="patch"){const A=D(t,this.blue);for(const k of A){const ye=E.patch.op==="move"||E.patch.op==="copy"?[E.patch.from,E.patch.path]:[E.patch.path],L=T.getNodePath(),Ee=ye.some(we=>R(we,k.absPath)),ve=R(L,k.absPath);if(Ee&&!ve)throw new W(E.patch,k.absPath,L)}try{t=H(t,[E.patch])}catch(k){throw je(d,p,k),k}}else E.kind==="event"&&(n.push(E.event.payload),await this.router.route(t,[],E.event,i.key[5]))});await g.handle(p,u,T,d),await T.flush()}return{state:t,emitted:n}}}class ge{process(e,t){const n=t.getValue();if(P(n)){const o=t.clone();return o.setValue(n),o.setProperties(void 0),o.setItems(void 0),o.setType(void 0),o}return e}postProcess(e,t){const n=t.getValue();if(P(n)&&e.getValue()!==n&&n!==void 0){const o=e.clone();return o.setValue(n),o}return e}}const Ge=Object.freeze(Object.defineProperty({__proto__:null,ExpressionPreserver:ge},Symbol.toStringTag,{value:"Module"}));function Ke(){return new m.MergingProcessors.SequentialMergingProcessor([new m.MergingProcessors.ValuePropagator,new ge,new m.MergingProcessors.TypeAssigner,new m.MergingProcessors.ListProcessor,new m.MergingProcessors.DictionaryProcessor,new m.MergingProcessors.BasicTypesVerifier])}exports.BlueDocumentProcessor=Qe;exports.ChannelEventCheckpointProcessor=ne;exports.CodeBlockEvaluationError=ee;exports.CompositeTimelineChannelProcessor=oe;exports.DocumentUpdateChannelProcessor=re;exports.EmbeddedDocumentModificationError=W;exports.EmbeddedNodeChannelProcessor=se;exports.ExpressionEvaluationError=Z;exports.InitializedMarkerProcessor=ae;exports.LifecycleEventChannelProcessor=ie;exports.MergingProcessors=Ge;exports.MyOSAgentChannelProcessor=le;exports.MyOSTimelineChannelProcessor=ce;exports.OperationProcessor=ue;exports.PatchApplicationError=_;exports.ProcessEmbeddedProcessor=de;exports.SequentialWorkflowOperationProcessor=pe;exports.SequentialWorkflowProcessor=U;exports.TimelineChannelProcessor=me;exports.TriggeredEventChannelProcessor=fe;exports.collectEmbeddedPathSpecs=D;exports.createDefaultMergingProcessor=Ke;
9
+ `}const i=await e.compileModule(s);return await i.instantiate(t,r),await i.evaluate({timeout:o.timeout??500,promise:!0,reference:!0,release:!0}),await i.namespace.get("default",{timeout:o.timeout??500,promise:!0,copy:!0,release:!0})}static deepClone(e){return typeof e>"u"?e:JSON.parse(JSON.stringify(e))}}class x{static createStandardBindings(e,t,n){const o=e.getBlue(),r=o.nodeToJson(t.payload,"simple"),s=p.isBigNumber(r)?r.toNumber():r;return{document:i=>{const c=e.get(i);return p.isBigNumber(c)?c.toNumber():C(c)?o.nodeToJson(c,"original"):c},event:s,steps:n}}}const xe=/^\$\{([\s\S]*)\}$/,Ve=/\$\{([\s\S]*?)\}/,T=a=>typeof a!="string"?!1:xe.test(a),D=a=>typeof a!="string"?!1:Ve.test(a),le=a=>{if(!T(a))throw new Error(`Invalid expression: ${a}`);return a.slice(2,-1)};class O{static createBindings(e,t,n){return x.createStandardBindings(e,t,n)}static async evaluate(e,t,n,o){const{coerceToString:r}=o;if(T(e)){const s=le(e),i=await q.evaluate({code:s,ctx:t,bindings:n});return r?String(i??""):i}if(D(e)){const i=`\`${String(e).replace(/`/g,"\\`")}\``,c=await q.evaluate({code:i,ctx:t,bindings:n});return String(c??"")}return r?String(e):e}}function F(a,e){const{op:t,path:n,val:o,from:r}=a;if((t==="move"||t==="copy")&&!r)throw new Error(`${t} operation requires 'from' path`);if((t==="add"||t==="replace")&&o===void 0)throw new Error(`${t} operation requires 'val' property`);const s={type:"Document Update",op:t,path:n};return o!==void 0&&(s.val=o),r!==void 0&&(s.from=r),e.jsonValueToNode(s)}function _e(a){return a.jsonValueToNode({type:"Document Processing Initiated"})}class Re{stepType="Update Document";supports(e){return p.BlueNodeTypeSchema.isTypeOf(e,l.UpdateDocumentSchema)}async execute(e,t,n,o,r){const s=n.getBlue();if(!p.BlueNodeTypeSchema.isTypeOf(e,l.UpdateDocumentSchema))return;const i=await this.evaluateChangeset(e.get("/changeset"),n,t,r),c=p.applyBlueNodePatch(e,{op:"replace",path:"/changeset",val:i}),d=n.getBlue().nodeToSchemaOutput(c,l.UpdateDocumentSchema);for(const u of d.changeset??[]){if(!u.path)continue;const h=await this.evaluateChangePath(u.path,n,t,r),y=u.val;if((u.op==="replace"||u.op==="add")&&E.isNonNullable(y)){const f=await this.evaluateChangeValue(y,n,t,r);n.addPatch({op:u.op,path:h,val:f}),n.emitEvent({payload:F({op:u.op,path:n.resolvePath(h),val:s.nodeToJson(f,"original")},s),emissionType:"update"})}u.op==="remove"&&(n.addPatch({op:u.op,path:h}),n.emitEvent({payload:F({op:u.op,path:n.resolvePath(h),val:null},s),emissionType:"update"}))}}async evaluateChangeset(e,t,n,o){const r=t.getBlue();if(T(e)){const s=le(e),i=await q.evaluate({code:s,ctx:t,bindings:x.createStandardBindings(t,n,o)});return r.jsonValueToNode(i??null)}if(C(e))return e;throw new Error("Invalid changeset: expected a string or document node")}async evaluateChangeValue(e,t,n,o){const r=e.getValue(),s=t.getBlue();if(T(r)||typeof r=="string"&&D(r)){const i=O.createBindings(t,n,o),c=await O.evaluate(String(r),t,i,{coerceToString:!T(r)});return s.jsonValueToNode(c??null)}return e}async evaluateChangePath(e,t,n,o){const r=O.createBindings(t,n,o);if(T(e)||D(e)){const s=await O.evaluate(e,t,r,{coerceToString:!0});return String(s??"")}return e}}class We{stepType="Trigger Event";supports(e){return p.BlueNodeTypeSchema.isTypeOf(e,l.TriggerEventSchema)}async execute(e,t,n){const o=n.getBlue();if(!p.BlueNodeTypeSchema.isTypeOf(e,l.TriggerEventSchema))return;const r=o.nodeToSchemaOutput(e,l.TriggerEventSchema);r.event&&n.emitEvent({payload:r.event,emissionType:"triggered"})}}class Je{stepType="JavaScript Code";supports(e){return p.BlueNodeTypeSchema.isTypeOf(e,l.JavaScriptCodeSchema)}async execute(e,t,n,o,r){if(!p.BlueNodeTypeSchema.isTypeOf(e,l.JavaScriptCodeSchema))return;const s=n.getBlue(),i=s.nodeToSchemaOutput(e,l.JavaScriptCodeSchema);if(!i.code)throw new Error("JavaScript code is required");const c=await q.evaluate({code:i.code,ctx:n,bindings:x.createStandardBindings(n,t,r),options:{isCodeBlock:!0,timeout:500}});if(c&&typeof c=="object"&&"events"in c){const d=c;if(Array.isArray(d.events))for(const u of d.events)n.emitEvent({payload:s.jsonValueToNode(u),emissionType:"triggered"})}return c}}const Ue=[new Re,new We,new Je];class V{contractType="Sequential Workflow";contractBlueId=l.blueIds["Sequential Workflow"];role="handler";executors=[];constructor(e=Ue){this.executors=e}registerExecutor(e){this.executors.push(e)}supports(e,t,n){const r=n.getBlue().nodeToSchemaOutput(t,l.SequentialWorkflowSchema),s=this.isChannelNameMatch(e,r),i=this.isEventPatternMatch(e,t,n);return s&&i}async handle(e,t,n,o){const r={},s=t.getProperties()?.steps.getItems();for(const[i,c]of(s??[]).entries()){const d=this.executors.find(h=>h.supports(c));if(!d)throw new Error(`Unsupported workflow step type "${c.getType()}"`);const u=await d.execute(c,e,n,o,r);if(u!==void 0){const h=c.getName(),y=typeof h=="string"?h:`Step${i+1}`;r[y]=u}await n.flush()}}isChannelNameMatch(e,t){const n=t.channel;return E.isNonNullable(n)&&e.source==="channel"&&e.channelName===n}isEventPatternMatch(e,t,n){const o=t.getProperties()?.event;if(!o)return!0;try{const r=n.getBlue(),s=r.resolve(e.payload);return r.isTypeOfNode(s,o)}catch(r){return console.warn("Error during event pattern matching:",r),!1}}}class ue{contractType="Sequential Workflow Operation";contractBlueId=l.blueIds["Sequential Workflow Operation"];role="handler";sequentialWorkflowProcessor;constructor(e){this.sequentialWorkflowProcessor=e||new V}supports(e,t,n){const s=n.getBlue().nodeToSchemaOutput(t,l.SequentialWorkflowOperationSchema).operation,i=e.channelName;return e.source==="channel"&&E.isNonNullable(i)&&E.isNonNullable(s)&&i===s}async handle(e,t,n,o){try{await this.sequentialWorkflowProcessor.handle(e,t,n,o)}catch(r){throw console.error("Error in SequentialWorkflowOperationProcessor.handle:",r),r}}}const X=a=>p.BlueNodeTypeSchema.isTypeOf(a.payload,l.TimelineEntrySchema);class de extends N{contractType="Timeline Channel";contractBlueId=l.blueIds["Timeline Channel"];supports(e,t,n){if(!this.baseSupports(e)||!X(e))return!1;const r=n.getBlue().nodeToSchemaOutput(e.payload,l.TimelineEntrySchema),s=n.getBlue().nodeToSchemaOutput(t,l.TimelineChannelSchema),i=r.timeline?.timelineId;return v(s.timelineId)&&v(i)&&i===s.timelineId}handle(e,t,n,o){X(e)&&n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}class he extends N{contractType="Triggered Event Channel";contractBlueId=l.blueIds["Triggered Event Channel"];supports(e){return this.baseSupports(e)?e.emissionType==="triggered":!1}handle(e,t,n,o){n.emitEvent({payload:e.payload,channelName:o,source:"channel"})}}const Le=[new ce,new ne,new te,new de,new se,new ae,new ee,new re,new he,new ie,new V,new ue,new oe];class ze{constructor(e,t=Le){this.blue=e,this.registry=new ke(t),this.queue=new Ie,this.router=new Me(this.blue,this.registry,this.queue,()=>++this.taskCounter,()=>++this.eventCounter),this.register(new Z(this.checkpointCache),9999)}taskCounter=0;eventCounter=0;registry;queue;router;checkpointCache=new De;register(e,t){this.registry.register(e,t)}async initialize(e){let t=L(I(e),this.blue);const n={payload:_e(this.blue),source:"internal",emissionType:"lifecycle"},o=[n.payload];await this.router.route(t,[],n,0);const r=await this.drainQueue(t);return t=r.state,o.push(...r.emitted),t=$e(t,this.blue),{state:k(t),emitted:o}}async processEvents(e,t){let n=L(I(e),this.blue);const o=[];if(!Y(n,this.blue))throw new Error("Document is not initialized");for(const r of t)try{const s={payload:r,source:"external"};await this.router.route(n,[],s,0);const i=await this.drainQueue(n);n=i.state,o.push(...i.emitted);const c=this.checkpointCache.flush(n);c.length&&(n=U(n,c))}finally{this.checkpointCache.clear()}return{state:k(n),emitted:o}}async drainQueue(e){let t=e;const n=[],o=1e4;let r=0;for(;this.queue.length;){if(++r>o)throw new Error("Possible cycle – too many iterations");const s=this.queue.pop(),{nodePath:i,contractName:c,contractNode:d,event:u}=s,h=t.get(i);if(!C(h)||!h.getContracts()?.[c]||!d.getType())continue;const y=this.registry.get(d.getType());if(!y){console.warn(`No processor registered for contract: ${c}`);continue}const f=new Q(()=>t,s,this.blue,async w=>{for(const g of w)if(g.kind==="patch"){const B=$(t,this.blue);for(const b of B){const me=g.patch.op==="move"||g.patch.op==="copy"?[g.patch.from,g.patch.path]:[g.patch.path],_=f.getNodePath(),fe=me.some(ye=>J(ye,b.absPath)),ge=J(_,b.absPath);if(fe&&!ge)throw new j(g.patch,b.absPath,_)}try{t=U(t,[g.patch])}catch(b){throw qe(c,u,b),b}}else g.kind==="event"&&(n.push(g.event.payload),await this.router.route(t,[],g.event,s.key[5]))});await y.handle(u,d,f,c),await f.flush()}return{state:t,emitted:n}}}class pe{process(e,t){const n=t.getValue();if(T(n)){const o=t.clone();return o.setValue(n),o.setProperties(void 0),o.setItems(void 0),o.setType(void 0),o}return e}postProcess(e,t){const n=t.getValue();if(T(n)&&e.getValue()!==n&&n!==void 0){const o=e.clone();return o.setValue(n),o}return e}}const He=Object.freeze(Object.defineProperty({__proto__:null,ExpressionPreserver:pe},Symbol.toStringTag,{value:"Module"}));function Fe(){return new p.MergingProcessors.SequentialMergingProcessor([new p.MergingProcessors.ValuePropagator,new pe,new p.MergingProcessors.TypeAssigner,new p.MergingProcessors.ListProcessor,new p.MergingProcessors.DictionaryProcessor,new p.MergingProcessors.BasicTypesVerifier])}exports.BlueDocumentProcessor=ze;exports.ChannelEventCheckpointProcessor=Z;exports.CodeBlockEvaluationError=K;exports.CompositeTimelineChannelProcessor=ee;exports.DocumentUpdateChannelProcessor=te;exports.EmbeddedDocumentModificationError=j;exports.EmbeddedNodeChannelProcessor=ne;exports.ExpressionEvaluationError=G;exports.InitializedMarkerProcessor=oe;exports.LifecycleEventChannelProcessor=re;exports.MergingProcessors=He;exports.MyOSAgentChannelProcessor=ae;exports.MyOSTimelineChannelProcessor=se;exports.OperationProcessor=ie;exports.PatchApplicationError=A;exports.ProcessEmbeddedProcessor=ce;exports.SequentialWorkflowOperationProcessor=ue;exports.SequentialWorkflowProcessor=V;exports.TimelineChannelProcessor=de;exports.TriggeredEventChannelProcessor=he;exports.collectEmbeddedPathSpecs=$;exports.createDefaultMergingProcessor=Fe;