// @bun
var{defineProperty:l,getOwnPropertyNames:w,getOwnPropertyDescriptor:p}=Object,m=Object.prototype.hasOwnProperty;function v(e){return this[e]}var W=(e)=>{var o=(k??=new WeakMap).get(e),i;if(o)return o;if(o=l({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var t of w(e))if(!m.call(o,t))l(o,t,{get:v.bind(e,t),enumerable:!(i=p(e,t))||i.enumerable})}return k.set(e,o),o},k;var h=(e)=>e;function c(e,o){this[e]=h.bind(null,o)}var S=(e,o)=>{for(var i in o)l(e,i,{get:o[i],enumerable:!0,configurable:!0,set:c.bind(o,i)})};var D=(e,o)=>()=>(e&&(o=e(e=0)),o);function V(e,o){if(!Boolean(e.runtime?.workflowDevkit||e.runtime?.capabilities?.adapters?.["workflow-devkit"]))return;let t=e.runtime?.workflowDevkit;if(!t){o.push({level:"warning",message:"Workflow enables the workflow-devkit adapter without defining runtime.workflowDevkit."});return}s(t.runIdentity?.prefix,"runtime.workflowDevkit.runIdentity.prefix",o),s(t.hookTokens?.prefix,"runtime.workflowDevkit.hookTokens.prefix",o);let f=t.serialization?.mode??"strict";if(f==="strict"){if((t.serialization?.enforceMetadata??!0)&&e.metadata!==void 0&&!n(e.metadata))d(o,"Workflow metadata must be JSON-serializable.");if((t.serialization?.enforceMetadata??!0)&&e.annotations!==void 0&&!n(e.annotations))d(o,"Workflow annotations must be JSON-serializable.")}for(let u of e.definition.steps)y(u,f,o)}function y(e,o,i){let t=e.runtime?.workflowDevkit;if(!t){if(e.type==="human")i.push({level:"warning",message:`Human step "${e.id}" does not define runtime.workflowDevkit wait behavior.`});return}if(g(e.id,t,i),e.type==="automation"&&e.retry&&(!t.idempotencyKey||t.idempotencyKey.trim().length===0))i.push({level:"error",message:`Retrying automation step "${e.id}" must define runtime.workflowDevkit.idempotencyKey.`});if(t.idempotencyKey!==void 0&&t.idempotencyKey.trim().length===0)i.push({level:"error",message:`Step "${e.id}" defines an empty runtime.workflowDevkit.idempotencyKey.`});if(o==="strict")r(e.id,"runtime.workflowDevkit.stateExample",t.stateExample,i),r(e.id,"runtime.workflowDevkit.hookWait.payloadExample",t.hookWait?.payloadExample,i),r(e.id,"runtime.workflowDevkit.webhookWait.payloadExample",t.webhookWait?.payloadExample,i),r(e.id,"runtime.workflowDevkit.approvalWait.payloadExample",t.approvalWait?.payloadExample,i),r(e.id,"runtime.workflowDevkit.streamSession.initialState",t.streamSession?.initialState,i)}function g(e,o,i){switch(o.behavior){case"sleep":if(!o.sleep?.duration.trim())b(e,o.behavior,"sleep.duration",i);return;case"hookWait":if(o.hookWait?.resumeSource!=="hook")a(e,o.behavior,"hook",i);return;case"webhookWait":if(o.webhookWait?.resumeSource!=="webhook")a(e,o.behavior,"webhook",i);return;case"approvalWait":if(o.approvalWait?.resumeSource!=="approval")a(e,o.behavior,"approval",i);return;case"streamSession":if(o.streamSession?.resumeSource!=="stream")a(e,o.behavior,"stream",i);return}}function b(e,o,i,t){t.push({level:"error",message:`Step "${e}" configures ${o} but is missing ${i}.`})}function d(e,o){e.push({level:"error",message:o})}function a(e,o,i,t){t.push({level:"error",message:`Step "${e}" configures ${o} but does not declare resumeSource "${i}".`})}function r(e,o,i,t){if(i===void 0)return;if(!n(i))t.push({level:"error",message:`Step "${e}" field ${o} must be JSON-serializable.`})}function s(e,o,i){if(e!==void 0&&e.trim().length===0)i.push({level:"error",message:`${o} must not be empty when provided.`})}function n(e,o=new Set){if(e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string")return!0;if(typeof e==="bigint"||typeof e==="function"||typeof e==="symbol"||e===void 0)return!1;if(o.has(e))return!1;if(o.add(e),Array.isArray(e))return e.every((i)=>n(i,o));if(Object.getPrototypeOf(e)!==Object.prototype)return!1;return Object.values(e).every((i)=>n(i,o))}export{V as validateWorkflowDevkitConfig};
