@manifesto-ai/sdk 5.1.0 → 5.1.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.
@@ -1 +1 @@
1
- import{c as G,g as X,h as J,l as j,o as Q}from"./chunk-DPFMD6LR.js";import{a as h,d as K,f as D}from"./chunk-TG2UPPZN.js";async function Y(e,o,s,c,l){let p=e.getCanonicalSnapshot(),f=o.projectSnapshot(p),T=e.evaluateIntentLegalityFor(p,c),x=e.deriveIntentAdmission(p,T);if(T.kind!=="admitted"){let A=x,y=ue(e,T),z={code:y.code,reason:y.message};return{kind:"rejected",intent:T.intent,admission:A,beforeSnapshot:f,beforeCanonicalSnapshot:p,rejection:z,rejectionError:y}}let N=x,b;try{b=await e.executeHost(T.intent,{context:l})}catch(A){let y=de(A);return{kind:"failed",intent:T.intent,admission:N,beforeSnapshot:f,beforeCanonicalSnapshot:p,failure:y,errorInfo:e.classifyExecutionFailure(y,"host"),published:!1}}let I=e.createExecutionDiagnostics(b);if(b.status==="error"){let A=b.error??new h("HOST_ERROR","Host dispatch failed"),{publishedCanonicalSnapshot:y}=s.publishFailedHostResult(b.snapshot);return{kind:"failed",intent:T.intent,admission:N,beforeSnapshot:f,beforeCanonicalSnapshot:p,failure:A,errorInfo:e.classifyExecutionFailure(A,"host"),published:!0,diagnostics:I,outcome:e.deriveExecutionOutcome(p,y)}}let{publishedSnapshot:M,publishedCanonicalSnapshot:C}=s.publishCompletedHostResult(b.snapshot);return{kind:"completed",intent:T.intent,admission:N,publishedSnapshot:M,outcome:e.deriveExecutionOutcome(p,C),diagnostics:I}}function ue(e,o){if(o.kind==="unavailable")return e.createUnavailableError(o.intent);if(o.kind==="invalid-input")return o.error;if(o.kind==="not-dispatchable")return e.createNotDispatchableError(o.intent);throw new h("SDK_REPORT_ERROR","Cannot derive a rejected dispatch error for an admitted intent")}function de(e){return e instanceof Error?e:new Error(String(e))}function V(e){let o;try{o=structuredClone(e)}catch(s){throw new h("INVALID_INPUT",`Action input must be structured-cloneable: ${s instanceof Error?s.message:String(s)}`)}return Z(o)}function H(e){try{return{ok:!0,value:V(e)}}catch(o){if(o instanceof h)return{ok:!1,error:o};throw o}}function Z(e,o=new WeakSet){if(e==null||typeof e!="object")return e;let s=e;if(o.has(s)||Object.isFrozen(e))return e;o.add(s);for(let c of Reflect.ownKeys(s))Z(s[c],o);return Object.freeze(e)}function me(e,o={},s=!1){let c=v(o),l=e[G],p=J({setVisibleSnapshot:e.setVisibleSnapshot,restoreVisibleSnapshot:e.restoreVisibleSnapshot,getCanonicalSnapshot:e.getCanonicalSnapshot}),f=new Map;for(let t of e.getActionMetadata())f.set(t.name,fe(t));let T=Object.create(null),x=new Map;for(let t of f.keys()){let n=z(t);x.set(t,n),Object.defineProperty(T,t,{enumerable:!0,configurable:!1,writable:!1,value:n})}function N(t,n){if(e.isDisposed())return()=>{};let i;try{i=t(e.getSnapshot())}catch{i=void 0}return e.subscribe(t,r=>{let u=i;i=r,n(r,u)})}let b=Object.freeze({state:N,event(t,n){return e.isDisposed()?()=>{}:e.on(t,n)}}),I=(t=>x.get(t)),M={action:Object.freeze(T),state:A(),computed:y(),observe:b,inspect:Object.freeze({graph:e.getSchemaGraph,canonicalSnapshot:e.getCanonicalSnapshot,action(t){return O(t)},availableActions(){return Object.freeze(e.getAvailableActions().map(t=>O(t)))},schemaHash(){return e.getCanonicalSnapshot().meta.schemaHash}}),snapshot:e.getSnapshot,getAction:I,context:U,injectContext(t){if(s){c=v({...c,context:e.captureExternalContext(t)});return}e.replaceExternalContext(t)},updateContext(t){if(!s)return e.updateExternalContext(t);let n=t(U());return c=v({...c,context:e.captureExternalContext(n)}),c.context??e.getExternalContext()},with(t){return me(e,oe(t),!0)},dispose:e.dispose};return Object.freeze(Q(M,e));function C(t,n,i){return Object.freeze({name:t,ref:n,value:()=>i(e.getSnapshot()),observe:r=>N(i,r)})}function A(){let t=Object.create(null);for(let n of Object.keys(e.refs.state)){let i=e.refs.state[n];Object.defineProperty(t,n,{enumerable:!0,configurable:!1,writable:!1,value:C(n,i,r=>r.state[n])})}return Object.freeze(t)}function y(){let t=Object.create(null);for(let n of Object.keys(e.refs.computed)){let i=e.refs.computed[n];Object.defineProperty(t,n,{enumerable:!0,configurable:!1,writable:!1,value:C(n,i,r=>r.computed[n])})}return Object.freeze(t)}function z(t){return Object.freeze({info:()=>O(t),available:()=>e.isActionAvailable(t),check:(...n)=>{let i=E(t,n);return k(i)},preview:(...n)=>{let i=E(t,n);return L(i)},submit:(...n)=>{let i=E(t,n);return _(i)},bind:(...n)=>te(t,n)})}function te(t,n){let i=E(t,n),r=H([...n]),u=()=>r.ok?E(t,r.value):i;return Object.freeze({action:t,input:i.input,check:()=>k(u()),preview:()=>L(u()),submit:()=>_(u()),intent:()=>{let a=u();return a.inputError?null:a.intent}})}function E(t,n){let i=e.refs.actions[t],r=ne(t,n),u=H(r);if(!u.ok)return Object.freeze({actionName:t,input:void 0,intent:null,inputError:u.error});try{let a=V(e.createIntent(i,...n)),d=e.validateIntentInputFor(e.getCanonicalSnapshot(),a);return Object.freeze({actionName:t,input:u.value,intent:a,inputError:d})}catch(a){if(!(a instanceof h))throw a;return Object.freeze({actionName:t,input:u.value,intent:null,inputError:a})}}function ne(t,n){return n.length===0?void 0:e.getActionMetadata(t).publicArity>1?Object.freeze([...n]):n.length===1?n[0]:Object.freeze([...n])}function k(t){let n=e.getCanonicalSnapshot();return B(t,n).admission}function L(t){let n=e.getCanonicalSnapshot(),i=l.projectSnapshot(n),r=B(t,n);if(!r.admission.ok||r.intent===null)return Object.freeze({admitted:!1,admission:r.admission});let u=r.intent,a=e.createComputeContext(u,P()),d=e.simulateSync(n,u,{context:a}),S=l.projectSnapshot(d.snapshot);return Object.freeze({admitted:!0,status:d.status,before:i,after:S,changes:X(i,S),requirements:d.requirements,newAvailableActions:e.getAvailableActionsFor(d.snapshot).map(R=>O(R)),...le(d.diagnostics,c.diagnostics),error:d.snapshot.system.lastError})}async function _(t){if(e.isDisposed())throw new K;let n=t.intent?e.createComputeContext(t.intent,P()):null;return e.enqueue(async()=>{if(e.isDisposed())throw new K;let i=e.getCanonicalSnapshot(),r=B(t,i);if(!r.admission.ok||r.intent===null){let m=r.admission;return q(t.actionName,t.intent,m,i),Object.freeze({ok:!1,mode:"base",action:t.actionName,admission:m})}let u=r.intent;ae(t.actionName,u,r.admission,i),re(t.actionName,u,i);let a=await Y(e,l,p,u,n??e.createComputeContext(u,P()));if(a.kind==="rejected"){let m=j(t.actionName,a.admission,a.rejection.reason);return q(t.actionName,a.intent,m,a.beforeCanonicalSnapshot),Object.freeze({ok:!1,mode:"base",action:t.actionName,admission:m})}if(a.kind==="failed"){let m=a.outcome?.canonical.afterCanonicalSnapshot??a.beforeCanonicalSnapshot,$=ee(m);if(!a.published||$||!m.system.lastError){let ce=$??be(a.failure,a.intent,m);throw F(t.actionName,a.intent,ce,m),new D(a.failure.message,"runtime",{cause:a.failure})}}let d=(a.kind==="completed",a.outcome);if(!d){let m=w(a.kind==="failed"?a.failure:new Error("Submission produced no terminal outcome"),a.intent,e.getCanonicalSnapshot());throw F(t.actionName,a.intent,m,e.getCanonicalSnapshot()),new D(m.message,"runtime")}let S=ye(d,a.intent,a.diagnostics),R=d.canonical.afterCanonicalSnapshot;if(d.canonical.status==="pending"){let m=w(new Error("Base submit produced a pending runtime snapshot"),a.intent,R);throw F(t.actionName,a.intent,m,R),new D(m.message,"runtime")}se(t.actionName,a.intent,S,R);let W=pe(c.report,t.actionName,d,S,a.diagnostics);return Object.freeze({ok:!0,mode:"base",status:"settled",action:t.actionName,before:d.projected.beforeSnapshot,after:d.projected.afterSnapshot,outcome:S,...W!==void 0?{report:W}:{}})})}function U(){return c.context??e.getExternalContext()}function P(){return c.context??e.captureExternalContext()}function oe(t){return v({...c,...t.context!==void 0?{context:e.captureExternalContext(t.context)}:{},...t.diagnostics!==void 0?{diagnostics:t.diagnostics}:{},...t.report!==void 0?{report:t.report}:{}})}function B(t,n){if(!e.isActionAvailableFor(n,t.actionName))return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"availability",code:"ACTION_UNAVAILABLE",message:`Action "${t.actionName}" is unavailable against the current visible snapshot`,blockers:ie(t,n)}),intent:null};if(t.inputError||!t.intent)return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"input",code:"INVALID_INPUT",message:t.inputError?.message??"Invalid action input",blockers:Object.freeze([])}),intent:null};let i=e.evaluateIntentLegalityFor(n,t.intent);if(i.kind==="admitted")return{admission:Object.freeze({ok:!0,action:t.actionName}),intent:i.intent};let r=e.deriveIntentAdmission(n,i);return{admission:j(t.actionName,r),intent:null}}function ie(t,n){if(!t.intent){let u=Object.freeze({type:String(t.actionName),intentId:`availability:${String(t.actionName)}`}),a=e.evaluateIntentLegalityFor(n,u),d=e.deriveIntentAdmission(n,a);return d.kind!=="blocked"||d.failure.kind!=="unavailable"?Object.freeze([]):j(t.actionName,d).blockers}let i=e.evaluateIntentLegalityFor(n,t.intent),r=e.deriveIntentAdmission(n,i);return r.kind!=="blocked"||r.failure.kind!=="unavailable"?Object.freeze([]):j(t.actionName,r).blockers}function O(t){let n=f.get(t);if(!n)throw new h("UNKNOWN_ACTION",`Action "${String(t)}" is not declared by this Manifesto schema`);return n}function ae(t,n,i,r){e.emitEvent("submission:admitted",{...g(t,n,r),admission:i})}function q(t,n,i,r){e.emitEvent("submission:rejected",{...g(t,n,r),admission:i})}function re(t,n,i){e.emitEvent("submission:submitted",g(t,n,i))}function se(t,n,i,r){e.emitEvent("submission:settled",{...g(t,n,r),outcome:i})}function F(t,n,i,r){e.emitEvent("submission:failed",{...g(t,n,r),stage:"runtime",error:i})}function g(t,n,i){return{action:t,mode:"base",...n?.intentId?{intentId:n.intentId}:{},schemaHash:i.meta.schemaHash,snapshotVersion:i.meta.version}}}function le(e,o){return!e||o==="none"?{}:o==="summary"?{diagnostics:{}}:{diagnostics:{trace:e.trace}}}function pe(e,o,s,c,l){if(e!=="none")return Object.freeze({mode:"base",action:String(o),changes:s.projected.changedPaths,requirements:s.canonical.pendingRequirements,outcome:c,...e==="full"&&l!==void 0?{diagnostics:l}:{}})}function v(e){return Object.freeze({...e})}function fe(e){let o=e.input?.type==="object"?e.input.fields??{}:{},s=e.params.length>0?e.params:Object.keys(o),c=e.annotations,l=typeof c?.title=="string"?c.title:void 0;return Object.freeze({name:e.name,...l!==void 0?{title:l}:{},...e.description!==void 0?{description:e.description}:{},parameters:Object.freeze(s.map(p=>{let f=o[p];return Object.freeze({name:p,required:f?.required??!0,...f?.type!==void 0?{type:Te(f.type)}:{},...f?.description!==void 0?{description:f.description}:{}})})),...c!==void 0?{annotations:c}:{}})}function Te(e){return typeof e=="string"?e:typeof e=="object"&&e!==null&&"enum"in e?"enum":"unknown"}function ye(e,o,s){let c=he(s);if(c!==null)return Object.freeze({kind:"stop",reason:c});let l=e.canonical.afterCanonicalSnapshot;return l.system.lastError?Object.freeze({kind:"fail",error:l.system.lastError}):e.canonical.status==="error"?Object.freeze({kind:"fail",error:w(new Error("Runtime completed with error status"),o,l)}):Object.freeze({kind:"ok"})}function he(e){let o=e?.hostTraces?.slice().reverse().find(s=>s.terminatedBy==="halt");if(!o)return null;for(let s of Object.values(o.nodes))if(s.kind==="halt"){let c=s.inputs.reason;return typeof c=="string"?c:"halted"}return"halted"}function w(e,o,s){return Object.freeze({code:e instanceof h?e.code:"SUBMISSION_FAILED",message:e.message,source:{actionId:o.intentId??"",nodePath:"runtime.submit"},timestamp:s.meta.timestamp})}function be(e,o,s){return Ae(s)??w(e,o,s)}function Ae(e){return e.system.lastError?e.system.lastError:ee(e)}function ee(e){let o=e.namespaces?.host;if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o.lastError;if(Ne(s))return s}return null}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let o=e;return typeof o.code=="string"&&typeof o.message=="string"&&typeof o.timestamp=="number"&&!!o.source&&typeof o.source=="object"&&typeof o.source.actionId=="string"&&typeof o.source.nodePath=="string"}export{me as a};
1
+ import{c as G,g as X,h as J,l as j,o as Q}from"./chunk-L7HPZ7ZD.js";import{a as h,d as K,f as D}from"./chunk-TG2UPPZN.js";async function Y(e,o,s,c,l){let p=e.getCanonicalSnapshot(),f=o.projectSnapshot(p),T=e.evaluateIntentLegalityFor(p,c),x=e.deriveIntentAdmission(p,T);if(T.kind!=="admitted"){let A=x,y=ue(e,T),z={code:y.code,reason:y.message};return{kind:"rejected",intent:T.intent,admission:A,beforeSnapshot:f,beforeCanonicalSnapshot:p,rejection:z,rejectionError:y}}let N=x,b;try{b=await e.executeHost(T.intent,{context:l})}catch(A){let y=de(A);return{kind:"failed",intent:T.intent,admission:N,beforeSnapshot:f,beforeCanonicalSnapshot:p,failure:y,errorInfo:e.classifyExecutionFailure(y,"host"),published:!1}}let I=e.createExecutionDiagnostics(b);if(b.status==="error"){let A=b.error??new h("HOST_ERROR","Host dispatch failed"),{publishedCanonicalSnapshot:y}=s.publishFailedHostResult(b.snapshot);return{kind:"failed",intent:T.intent,admission:N,beforeSnapshot:f,beforeCanonicalSnapshot:p,failure:A,errorInfo:e.classifyExecutionFailure(A,"host"),published:!0,diagnostics:I,outcome:e.deriveExecutionOutcome(p,y)}}let{publishedSnapshot:M,publishedCanonicalSnapshot:C}=s.publishCompletedHostResult(b.snapshot);return{kind:"completed",intent:T.intent,admission:N,publishedSnapshot:M,outcome:e.deriveExecutionOutcome(p,C),diagnostics:I}}function ue(e,o){if(o.kind==="unavailable")return e.createUnavailableError(o.intent);if(o.kind==="invalid-input")return o.error;if(o.kind==="not-dispatchable")return e.createNotDispatchableError(o.intent);throw new h("SDK_REPORT_ERROR","Cannot derive a rejected dispatch error for an admitted intent")}function de(e){return e instanceof Error?e:new Error(String(e))}function V(e){let o;try{o=structuredClone(e)}catch(s){throw new h("INVALID_INPUT",`Action input must be structured-cloneable: ${s instanceof Error?s.message:String(s)}`)}return Z(o)}function H(e){try{return{ok:!0,value:V(e)}}catch(o){if(o instanceof h)return{ok:!1,error:o};throw o}}function Z(e,o=new WeakSet){if(e==null||typeof e!="object")return e;let s=e;if(o.has(s)||Object.isFrozen(e))return e;o.add(s);for(let c of Reflect.ownKeys(s))Z(s[c],o);return Object.freeze(e)}function me(e,o={},s=!1){let c=v(o),l=e[G],p=J({setVisibleSnapshot:e.setVisibleSnapshot,restoreVisibleSnapshot:e.restoreVisibleSnapshot,getCanonicalSnapshot:e.getCanonicalSnapshot}),f=new Map;for(let t of e.getActionMetadata())f.set(t.name,fe(t));let T=Object.create(null),x=new Map;for(let t of f.keys()){let n=z(t);x.set(t,n),Object.defineProperty(T,t,{enumerable:!0,configurable:!1,writable:!1,value:n})}function N(t,n){if(e.isDisposed())return()=>{};let i;try{i=t(e.getSnapshot())}catch{i=void 0}return e.subscribe(t,r=>{let u=i;i=r,n(r,u)})}let b=Object.freeze({state:N,event(t,n){return e.isDisposed()?()=>{}:e.on(t,n)}}),I=(t=>x.get(t)),M={action:Object.freeze(T),state:A(),computed:y(),observe:b,inspect:Object.freeze({graph:e.getSchemaGraph,canonicalSnapshot:e.getCanonicalSnapshot,action(t){return O(t)},availableActions(){return Object.freeze(e.getAvailableActions().map(t=>O(t)))},schemaHash(){return e.getCanonicalSnapshot().meta.schemaHash}}),snapshot:e.getSnapshot,getAction:I,context:U,injectContext(t){if(s){c=v({...c,context:e.captureExternalContext(t)});return}e.replaceExternalContext(t)},updateContext(t){if(!s)return e.updateExternalContext(t);let n=t(U());return c=v({...c,context:e.captureExternalContext(n)}),c.context??e.getExternalContext()},with(t){return me(e,oe(t),!0)},dispose:e.dispose};return Object.freeze(Q(M,e));function C(t,n,i){return Object.freeze({name:t,ref:n,value:()=>i(e.getSnapshot()),observe:r=>N(i,r)})}function A(){let t=Object.create(null);for(let n of Object.keys(e.refs.state)){let i=e.refs.state[n];Object.defineProperty(t,n,{enumerable:!0,configurable:!1,writable:!1,value:C(n,i,r=>r.state[n])})}return Object.freeze(t)}function y(){let t=Object.create(null);for(let n of Object.keys(e.refs.computed)){let i=e.refs.computed[n];Object.defineProperty(t,n,{enumerable:!0,configurable:!1,writable:!1,value:C(n,i,r=>r.computed[n])})}return Object.freeze(t)}function z(t){return Object.freeze({info:()=>O(t),available:()=>e.isActionAvailable(t),check:(...n)=>{let i=E(t,n);return k(i)},preview:(...n)=>{let i=E(t,n);return L(i)},submit:(...n)=>{let i=E(t,n);return _(i)},bind:(...n)=>te(t,n)})}function te(t,n){let i=E(t,n),r=H([...n]),u=()=>r.ok?E(t,r.value):i;return Object.freeze({action:t,input:i.input,check:()=>k(u()),preview:()=>L(u()),submit:()=>_(u()),intent:()=>{let a=u();return a.inputError?null:a.intent}})}function E(t,n){let i=e.refs.actions[t],r=ne(t,n),u=H(r);if(!u.ok)return Object.freeze({actionName:t,input:void 0,intent:null,inputError:u.error});try{let a=V(e.createIntent(i,...n)),d=e.validateIntentInputFor(e.getCanonicalSnapshot(),a);return Object.freeze({actionName:t,input:u.value,intent:a,inputError:d})}catch(a){if(!(a instanceof h))throw a;return Object.freeze({actionName:t,input:u.value,intent:null,inputError:a})}}function ne(t,n){return n.length===0?void 0:e.getActionMetadata(t).publicArity>1?Object.freeze([...n]):n.length===1?n[0]:Object.freeze([...n])}function k(t){let n=e.getCanonicalSnapshot();return B(t,n).admission}function L(t){let n=e.getCanonicalSnapshot(),i=l.projectSnapshot(n),r=B(t,n);if(!r.admission.ok||r.intent===null)return Object.freeze({admitted:!1,admission:r.admission});let u=r.intent,a=e.createComputeContext(u,P()),d=e.simulateSync(n,u,{context:a}),S=l.projectSnapshot(d.snapshot);return Object.freeze({admitted:!0,status:d.status,before:i,after:S,changes:X(i,S),requirements:d.requirements,newAvailableActions:e.getAvailableActionsFor(d.snapshot).map(R=>O(R)),...le(d.diagnostics,c.diagnostics),error:d.snapshot.system.lastError})}async function _(t){if(e.isDisposed())throw new K;let n=t.intent?e.createComputeContext(t.intent,P()):null;return e.enqueue(async()=>{if(e.isDisposed())throw new K;let i=e.getCanonicalSnapshot(),r=B(t,i);if(!r.admission.ok||r.intent===null){let m=r.admission;return q(t.actionName,t.intent,m,i),Object.freeze({ok:!1,mode:"base",action:t.actionName,admission:m})}let u=r.intent;ae(t.actionName,u,r.admission,i),re(t.actionName,u,i);let a=await Y(e,l,p,u,n??e.createComputeContext(u,P()));if(a.kind==="rejected"){let m=j(t.actionName,a.admission,a.rejection.reason);return q(t.actionName,a.intent,m,a.beforeCanonicalSnapshot),Object.freeze({ok:!1,mode:"base",action:t.actionName,admission:m})}if(a.kind==="failed"){let m=a.outcome?.canonical.afterCanonicalSnapshot??a.beforeCanonicalSnapshot,$=ee(m);if(!a.published||$||!m.system.lastError){let ce=$??be(a.failure,a.intent,m);throw F(t.actionName,a.intent,ce,m),new D(a.failure.message,"runtime",{cause:a.failure})}}let d=(a.kind==="completed",a.outcome);if(!d){let m=w(a.kind==="failed"?a.failure:new Error("Submission produced no terminal outcome"),a.intent,e.getCanonicalSnapshot());throw F(t.actionName,a.intent,m,e.getCanonicalSnapshot()),new D(m.message,"runtime")}let S=ye(d,a.intent,a.diagnostics),R=d.canonical.afterCanonicalSnapshot;if(d.canonical.status==="pending"){let m=w(new Error("Base submit produced a pending runtime snapshot"),a.intent,R);throw F(t.actionName,a.intent,m,R),new D(m.message,"runtime")}se(t.actionName,a.intent,S,R);let W=pe(c.report,t.actionName,d,S,a.diagnostics);return Object.freeze({ok:!0,mode:"base",status:"settled",action:t.actionName,before:d.projected.beforeSnapshot,after:d.projected.afterSnapshot,outcome:S,...W!==void 0?{report:W}:{}})})}function U(){return c.context??e.getExternalContext()}function P(){return c.context??e.captureExternalContext()}function oe(t){return v({...c,...t.context!==void 0?{context:e.captureExternalContext(t.context)}:{},...t.diagnostics!==void 0?{diagnostics:t.diagnostics}:{},...t.report!==void 0?{report:t.report}:{}})}function B(t,n){if(!e.isActionAvailableFor(n,t.actionName))return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"availability",code:"ACTION_UNAVAILABLE",message:`Action "${t.actionName}" is unavailable against the current visible snapshot`,blockers:ie(t,n)}),intent:null};if(t.inputError||!t.intent)return{admission:Object.freeze({ok:!1,action:t.actionName,layer:"input",code:"INVALID_INPUT",message:t.inputError?.message??"Invalid action input",blockers:Object.freeze([])}),intent:null};let i=e.evaluateIntentLegalityFor(n,t.intent);if(i.kind==="admitted")return{admission:Object.freeze({ok:!0,action:t.actionName}),intent:i.intent};let r=e.deriveIntentAdmission(n,i);return{admission:j(t.actionName,r),intent:null}}function ie(t,n){if(!t.intent){let u=Object.freeze({type:String(t.actionName),intentId:`availability:${String(t.actionName)}`}),a=e.evaluateIntentLegalityFor(n,u),d=e.deriveIntentAdmission(n,a);return d.kind!=="blocked"||d.failure.kind!=="unavailable"?Object.freeze([]):j(t.actionName,d).blockers}let i=e.evaluateIntentLegalityFor(n,t.intent),r=e.deriveIntentAdmission(n,i);return r.kind!=="blocked"||r.failure.kind!=="unavailable"?Object.freeze([]):j(t.actionName,r).blockers}function O(t){let n=f.get(t);if(!n)throw new h("UNKNOWN_ACTION",`Action "${String(t)}" is not declared by this Manifesto schema`);return n}function ae(t,n,i,r){e.emitEvent("submission:admitted",{...g(t,n,r),admission:i})}function q(t,n,i,r){e.emitEvent("submission:rejected",{...g(t,n,r),admission:i})}function re(t,n,i){e.emitEvent("submission:submitted",g(t,n,i))}function se(t,n,i,r){e.emitEvent("submission:settled",{...g(t,n,r),outcome:i})}function F(t,n,i,r){e.emitEvent("submission:failed",{...g(t,n,r),stage:"runtime",error:i})}function g(t,n,i){return{action:t,mode:"base",...n?.intentId?{intentId:n.intentId}:{},schemaHash:i.meta.schemaHash,snapshotVersion:i.meta.version}}}function le(e,o){return!e||o==="none"?{}:o==="summary"?{diagnostics:{}}:{diagnostics:{trace:e.trace}}}function pe(e,o,s,c,l){if(e!=="none")return Object.freeze({mode:"base",action:String(o),changes:s.projected.changedPaths,requirements:s.canonical.pendingRequirements,outcome:c,...e==="full"&&l!==void 0?{diagnostics:l}:{}})}function v(e){return Object.freeze({...e})}function fe(e){let o=e.input?.type==="object"?e.input.fields??{}:{},s=e.params.length>0?e.params:Object.keys(o),c=e.annotations,l=typeof c?.title=="string"?c.title:void 0;return Object.freeze({name:e.name,...l!==void 0?{title:l}:{},...e.description!==void 0?{description:e.description}:{},parameters:Object.freeze(s.map(p=>{let f=o[p];return Object.freeze({name:p,required:f?.required??!0,...f?.type!==void 0?{type:Te(f.type)}:{},...f?.description!==void 0?{description:f.description}:{}})})),...c!==void 0?{annotations:c}:{}})}function Te(e){return typeof e=="string"?e:typeof e=="object"&&e!==null&&"enum"in e?"enum":"unknown"}function ye(e,o,s){let c=he(s);if(c!==null)return Object.freeze({kind:"stop",reason:c});let l=e.canonical.afterCanonicalSnapshot;return l.system.lastError?Object.freeze({kind:"fail",error:l.system.lastError}):e.canonical.status==="error"?Object.freeze({kind:"fail",error:w(new Error("Runtime completed with error status"),o,l)}):Object.freeze({kind:"ok"})}function he(e){let o=e?.hostTraces?.slice().reverse().find(s=>s.terminatedBy==="halt");if(!o)return null;for(let s of Object.values(o.nodes))if(s.kind==="halt"){let c=s.inputs.reason;return typeof c=="string"?c:"halted"}return"halted"}function w(e,o,s){return Object.freeze({code:e instanceof h?e.code:"SUBMISSION_FAILED",message:e.message,source:{actionId:o.intentId??"",nodePath:"runtime.submit"},timestamp:s.meta.timestamp})}function be(e,o,s){return Ae(s)??w(e,o,s)}function Ae(e){return e.system.lastError?e.system.lastError:ee(e)}function ee(e){let o=e.namespaces?.host;if(o&&typeof o=="object"&&!Array.isArray(o)){let s=o.lastError;if(Ne(s))return s}return null}function Ne(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let o=e;return typeof o.code=="string"&&typeof o.message=="string"&&typeof o.timestamp=="number"&&!!o.source&&typeof o.source=="object"&&typeof o.source.actionId=="string"&&typeof o.source.nodePath=="string"}export{me as a};
@@ -0,0 +1 @@
1
+ import{a as b,e as W}from"./chunk-TG2UPPZN.js";import{evaluateComputed as St,evaluateActionAvailability as Tt,evaluateAvailableActions as bt,evaluateIntentDispatchability as At,isErr as Ct}from"@manifesto-ai/core";import{extractSchemaGraph as xt}from"@manifesto-ai/compiler";function kt(e){return{visibleComputedKeys:Object.keys(e.computed.fields)}}function Y(e,t){return{state:qe(e.state),computed:We(e.computed,t),system:{status:e.system.status,lastError:e.system.lastError},meta:{schemaHash:e.meta.schemaHash}}}function vt(e,t){return Y(e,t)}function j(e){return ye(structuredClone(e))}function he(e,t){return Ye(e,t)}function qe(e){return structuredClone(e)}function We(e,t){let n={};for(let o of t.visibleComputedKeys)Object.hasOwn(e,o)&&(n[o]=e[o]);return structuredClone(n)}function Ye(e,t){return P(e,t,new WeakMap)}function P(e,t,n){if(Object.is(e,t))return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;let o=e,a=t,y=Object.prototype.toString.call(o),i=Object.prototype.toString.call(a);if(y!==i)return!1;let r=n.get(o);if(r?.has(a))return!0;if(r||(r=new WeakSet,n.set(o,r)),r.add(a),Array.isArray(o)&&Array.isArray(a)){if(o.length!==a.length)return!1;for(let c=0;c<o.length;c+=1){let h=Object.hasOwn(o,c),C=Object.hasOwn(a,c);if(h!==C||h&&!P(o[c],a[c],n))return!1}return!0}if(o instanceof Date&&a instanceof Date)return o.getTime()===a.getTime();if(o instanceof RegExp&&a instanceof RegExp)return o.source===a.source&&o.flags===a.flags;if(ArrayBuffer.isView(o)&&ArrayBuffer.isView(a)){if(o.constructor!==a.constructor||o.byteLength!==a.byteLength)return!1;let c=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),h=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return c.every((C,A)=>C===h[A])}if(o instanceof ArrayBuffer&&a instanceof ArrayBuffer){if(o.byteLength!==a.byteLength)return!1;let c=new Uint8Array(o),h=new Uint8Array(a);return c.every((C,A)=>C===h[A])}if(o instanceof Map&&a instanceof Map){if(o.size!==a.size)return!1;let c=Array.from(o.entries()),h=Array.from(a.entries());return c.every(([C,A],T)=>{let g=h[T];if(!g)return!1;let[x,O]=g;return P(C,x,n)&&P(A,O,n)})}if(o instanceof Set&&a instanceof Set){if(o.size!==a.size)return!1;let c=Array.from(o.values()),h=Array.from(a.values());return c.every((C,A)=>P(C,h[A],n))}let l=fe(o),p=fe(a);if(l.length!==p.length)return!1;for(let c=0;c<l.length;c+=1){let h=l[c],C=p[c];if(h!==C)return!1;let A=o[h],T=a[C];if(!P(A,T,n))return!1}return!0}function fe(e){return Object.keys(e).filter(t=>e[t]!==void 0).sort()}function ye(e,t=new WeakSet){if(e==null||typeof e!="object")return e;if(me(e))return Se(e);let n=e;if(t.has(n)||Object.isFrozen(e))return e;t.add(n);for(let o of Reflect.ownKeys(n)){let a=n[o];if(me(a)){Xe(n,o,a);continue}ye(a,t)}return Object.freeze(e)}function me(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}function Se(e){return structuredClone(e)}function Xe(e,t,n){let o=Object.getOwnPropertyDescriptor(e,t);!o||!("value"in o)||Object.defineProperty(e,t,{enumerable:o.enumerable??!0,configurable:!1,get(){return Se(n)}})}var X=Symbol("manifesto-sdk.action-param-names"),Qe=Symbol("manifesto-sdk.action-single-param-object-value"),U=Symbol("manifesto-sdk.runtime-kernel-factory"),z=Symbol("manifesto-sdk.activation-state"),N=Symbol("manifesto-sdk.extension-kernel");var Ze=/^(state|computed|action):.+$/;function Q(e){let t=new Set(e.nodes.map(r=>r.id)),n=new Map,o=new Map,a=(r,l,p)=>{let c=r.get(l);if(c){c.add(p);return}r.set(l,new Set([p]))};for(let r of e.edges)a(n,r.from,r.to),a(o,r.to,r.from);let y=r=>{let l=Object.freeze({nodes:Object.freeze(e.nodes.filter(p=>r.has(p.id))),edges:Object.freeze(e.edges.filter(p=>r.has(p.from)&&r.has(p.to)))});return Q(l)},i=(r,l)=>{let p=et(r,t),c=[p],h=new Set([p]),C=l==="incoming"?o:n;for(;c.length>0;){let A=c.shift();if(A)for(let T of C.get(A)??[])h.has(T)||(h.add(T),c.push(T))}return y(h)};return Object.freeze({nodes:e.nodes,edges:e.edges,traceUp(r){return i(r,"incoming")},traceDown(r){return i(r,"outgoing")}})}function et(e,t){if(typeof e=="string"){if(!Ze.test(e))throw new b("SCHEMA_ERROR",'SchemaGraph node id must use "state:<name>", "computed:<name>", or "action:<name>"');if(!t.has(e))throw new b("SCHEMA_ERROR",`Unknown SchemaGraph node id "${e}"`);return e}let n;switch(e.__kind){case"ActionRef":n=`action:${String(e.name)}`;break;case"FieldRef":n=`state:${e.name}`;break;case"ComputedRef":n=`computed:${e.name}`;break;default:throw new b("SCHEMA_ERROR","Unsupported SchemaGraph ref lookup target")}if(!t.has(n))throw new b("SCHEMA_ERROR",`SchemaGraph node "${n}" is not part of the projected graph`);return n}import{validateIntentInput as ot}from"@manifesto-ai/core";function be({getAvailableActionsFor:e,projectSnapshotFromCanonical:t}){function n(i,r){let l=e(i),p=e(r),c=Object.freeze(p.filter(C=>!l.includes(C))),h=Object.freeze(l.filter(C=>!p.includes(C)));return Object.freeze({before:l,after:p,unlocked:c,locked:h})}function o(i,r){let l=j(i),p=j(r),c=t(l),h=t(p);return Object.freeze({projected:Object.freeze({beforeSnapshot:c,afterSnapshot:h,changedPaths:B(c,h),availability:n(l,p)}),canonical:Object.freeze({beforeCanonicalSnapshot:l,afterCanonicalSnapshot:p,pendingRequirements:p.system.pendingRequirements,status:p.system.status})})}function a(i,r){let l=nt(i),p=l;return Object.freeze({message:l.message,...typeof p.code=="string"?{code:p.code}:{},...typeof l.name=="string"?{name:l.name}:{},stage:r})}function y(i){return Object.freeze({hostTraces:j(i.traces)})}return Object.freeze({deriveExecutionOutcome:o,classifyExecutionFailure:a,createExecutionDiagnostics:y})}function B(e,t){let n=new Map,o=new WeakMap,a=(i,r)=>{let l=tt(i);n.set(l,Object.freeze({path:Object.freeze([...i]),kind:r}))},y=(i,r,l)=>{if(Object.is(i,r))return;if(i===null||r===null){a(l,"changed");return}if(typeof i!="object"||typeof r!="object"){a(l,"changed");return}let p=i,c=r,h=o.get(p);if(h?.has(c))return;if(h?h.add(c):o.set(p,new WeakSet([c])),Array.isArray(i)||Array.isArray(r)){if(!Array.isArray(i)||!Array.isArray(r)){a(l,"changed");return}let A=Math.max(i.length,r.length);for(let T=0;T<A;T+=1){let g=Object.hasOwn(i,T),x=Object.hasOwn(r,T),O=[...l,T];if(g!==x){a(O,g?"unset":"set");continue}!g&&!x||y(i[T],r[T],O)}return}if(!Te(i)||!Te(r)){a(l,"changed");return}let C=new Set([...Object.keys(i),...Object.keys(r)]);for(let A of[...C].sort()){let T=Object.hasOwn(i,A),g=Object.hasOwn(r,A),x=[...l,A];if(T!==g){a(x,T?"unset":"set");continue}y(i[A],r[A],x)}};return y(e.state,t.state,["state"]),y(e.computed,t.computed,["computed"]),y(e.system,t.system,["system"]),y(e.meta,t.meta,["meta"]),Object.freeze([...n.entries()].sort(([i],[r])=>i.localeCompare(r)).map(([,i])=>i))}function Te(e){return Object.prototype.toString.call(e)==="[object Object]"}function tt(e){return e.map(t=>typeof t=="number"?`[${t}]`:t).join(".")}function nt(e){return e instanceof Error?e:new Error(String(e))}function Ae({schema:e,ensureIntentId:t,getAvailableActionsFor:n,isActionAvailableFor:o,evaluateActionAvailabilityFor:a,evaluateIntentDispatchabilityFor:y,projectSnapshotFromCanonical:i,getSimulateSync:r}){function l(S,m,u){return Object.freeze({layer:S,expression:m,evaluatedResult:!1,...u!==void 0?{description:u}:{}})}function p(S,m){let u=m.type,d=e.actions[u];if(!d)return Object.freeze([]);let I=a(S,u);if(I.kind==="error")return Object.freeze(d.available?[l("available",d.available,I.message)]:[]);if(!I.available)return Object.freeze(d.available?[l("available",d.available,d.description)]:[]);let E=y(S,m);return E.kind==="error"?Object.freeze(d.dispatchable?[l("dispatchable",d.dispatchable,E.message)]:[]):E.dispatchable?Object.freeze([]):Object.freeze(d.dispatchable?[l("dispatchable",d.dispatchable,d.description)]:[])}function c(S){return new b("ACTION_UNAVAILABLE",`Action "${S.type}" is unavailable against the current visible snapshot`)}function h(S){return new b("INTENT_NOT_DISPATCHABLE",`Action "${S.type}" is available, but the bound intent is not dispatchable against the current visible snapshot`)}function C(S){return new b("INVALID_INPUT",S)}function A(S,m){let u=ot(e,m);return u?C(u):null}function T(S,m){let u=t(m),d=u.type;if(!o(S,d))return{kind:"unavailable",intent:u,actionName:d};let I=A(S,u);if(I)return{kind:"invalid-input",intent:u,actionName:d,error:I};let E=p(S,u);return E.length>0?{kind:"not-dispatchable",intent:u,actionName:d,blockers:E}:{kind:"admitted",intent:u,actionName:d}}function g(S,m){return m.kind==="unavailable"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"unavailable",blockers:p(S,m.intent)}}):m.kind==="invalid-input"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"invalid_input",error:{code:"INVALID_INPUT",message:m.error.message}}}):m.kind==="not-dispatchable"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"not_dispatchable",blockers:m.blockers}}):Object.freeze({kind:"admitted",actionName:m.actionName})}function x(S,m){let u=T(S,m);if(u.kind==="unavailable")return Object.freeze({kind:"blocked",actionName:u.actionName,available:!1,dispatchable:!1,blockers:p(S,u.intent)});if(u.kind==="invalid-input")throw u.error;if(u.kind==="not-dispatchable")return Object.freeze({kind:"blocked",actionName:u.actionName,available:!0,dispatchable:!1,blockers:u.blockers});let d=r()(S,u.intent),I=i(S),E=i(d.snapshot);return Object.freeze({kind:"admitted",actionName:u.actionName,available:!0,dispatchable:!0,status:d.status,requirements:d.requirements,canonicalSnapshot:d.snapshot,snapshot:E,newAvailableActions:n(d.snapshot),changedPaths:B(I,E)})}function O(S,m){throw m}function _(S){return O(S,c(S))}function L(S,m){return O(S,C(m))}function V(S){return O(S,h(S))}return Object.freeze({getIntentBlockersFor:p,validateIntentInputFor:A,evaluateIntentLegalityFor:T,deriveIntentAdmission:g,explainIntentFor:x,createUnavailableError:c,createNotDispatchableError:h,rejectInvalidInput:L,rejectUnavailable:_,rejectNotDispatchable:V})}function Ce({setVisibleSnapshot:e,restoreVisibleSnapshot:t,getCanonicalSnapshot:n}){function o(i,r){return e(i,r)}function a(i){let r=o(i);return Object.freeze({publishedSnapshot:r,publishedCanonicalSnapshot:n()})}function y(i){let r=o(i);return Object.freeze({publishedSnapshot:r,publishedCanonicalSnapshot:n()})}return Object.freeze({replaceVisibleSnapshot:o,restoreVisibleSnapshot:t,publishCompletedHostResult:a,publishFailedHostResult:y})}import{apply as at,applyNamespaceDeltas as xe,applySystemDelta as rt,computeSync as it}from"@manifesto-ai/core";import{getHostState as st}from"@manifesto-ai/host/tooling";function Ee(e,t){return{...e,timestamp:t,children:e.children.map(n=>Ee(n,t))}}function ct(e){let t={};function n(o){t[o.id]=o,o.children.forEach(n)}return n(e),t}function lt(e,t){let n=Ee(e.root,t);return{...e,duration:0,root:n,nodes:ct(n)}}function Re({schema:e,hostContextProvider:t,evaluateIntentLegalityFor:n}){function o(r,l){let c=st(r)?.intentSlots??{},h=l.input===void 0?{type:l.type}:{type:l.type,input:l.input};return xe(r,[{namespace:"host",patches:[{op:"set",path:[{kind:"prop",name:"intentSlots"}],value:{...c,[l.intentId]:h}}]}])}function a(r){return new b("ACTION_UNAVAILABLE",`Action "${r.type}" is unavailable against the provided canonical snapshot`)}function y(r){return new b("INTENT_NOT_DISPATCHABLE",`Action "${r.type}" is available, but the bound intent is not dispatchable against the provided canonical snapshot`)}return Object.freeze({withHostIntentSlot:o,createSimulationUnavailableError:a,createSimulationNotDispatchableError:y,simulateSync:(r,l,p)=>{let c=n(r,l);if(c.kind==="unavailable")throw a(c.intent);if(c.kind==="invalid-input")throw c.error;if(c.kind==="not-dispatchable")throw y(c.intent);let h=c.intent,C=p?.context??t.createFrozenContext(h.intentId,p?.externalContext),A=o(structuredClone(r),h),T=it(e,A,h,C),g=at(e,A,T.patches),x=xe(g,T.namespaceDelta??[]),O=rt(x,T.systemDelta);return Object.freeze({snapshot:j(O),patches:j(T.patches),systemDelta:j(T.systemDelta),status:T.status,requirements:j(T.systemDelta.addRequirements??[]),diagnostics:Object.freeze({trace:j(lt(T.trace,r.meta.timestamp))})})}})}import{findJsonValueViolation as Z}from"@manifesto-ai/core";var ut=["state","computed","system","meta","namespaces"];function H(e){if(e===null||typeof e!="object"||Array.isArray(e))return Z(e,"snapshot");let t=e;for(let n of ut){let o=Z(t[n],`snapshot.${n}`);if(o)return o}return t.input===void 0?null:Z(t.input,"snapshot.input")}var pt=new Set(["state","computed","system","input","meta","namespaces"]),dt=["state","system","meta"];function ft(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new b("INVALID_SNAPSHOT_SHAPE","Visible snapshot must be a canonical snapshot object");let t=e,n=Object.keys(t).filter(o=>!pt.has(o));if(n.length>0){let o=n.includes("data")?' Domain state lives under "state" since v5; the v4 "data" key was renamed.':"";throw new b("INVALID_SNAPSHOT_SHAPE",`Visible snapshot has unknown top-level key(s): ${n.join(", ")}.${o} Expected only: state, computed, system, input, meta, namespaces.`)}for(let o of dt){let a=t[o];if(a===null||typeof a!="object"||Array.isArray(a))throw new b("INVALID_SNAPSHOT_SHAPE",`Visible snapshot is missing the required "${o}" object`)}}function mt(e){let t=H(e);if(t)throw new b("INVALID_SNAPSHOT_VALUE",`Visible snapshot contains a non-JSON value at ${t.path}: ${t.reason}`)}function Ie({host:e,initialCanonicalSnapshot:t,projectSnapshotFromCanonical:n}){let o=structuredClone(t),a=n(o),y=j(o),i=Promise.resolve(),r=!1,l=new Set,p=new Map;function c(m,u){if(r)return()=>{};let d,I=!1;try{d=m(a),I=!0}catch{d=void 0,I=!1}let E={selector:m,listener:u,lastValue:d,initialized:I};return l.add(E),()=>{l.delete(E)}}function h(m,u){if(r)return()=>{};let d=p.get(m);return d||(d=new Set,p.set(m,d)),d.add(u),()=>{d?.delete(u)}}function C(){return a}function A(){return y}function T(){return structuredClone(o)}function g(m,u){ft(m),mt(m),o=structuredClone(m),e.reset(structuredClone(o)),y=j(o);let d=n(o),I=!he(d,a);return I&&(a=d),u?.notify!==!1&&I&&S(a),a}function x(){e.reset(structuredClone(o))}function O(m,u){let d=p.get(m);if(d)for(let I of d)try{I(u)}catch{}}function _(m){let u=i.catch(()=>{}).then(m);return i=u.then(()=>{},()=>{}),u}function L(){r||(r=!0,l.clear(),p.clear())}function V(){return r}function S(m){for(let u of l){let d;try{d=u.selector(m)}catch{continue}if(!(u.initialized&&Object.is(u.lastValue,d))){u.lastValue=d,u.initialized=!0;try{u.listener(d)}catch{}}}}return{subscribe:c,on:h,getSnapshot:C,getCanonicalSnapshot:A,getVisibleCoreSnapshot:T,setVisibleSnapshot:g,restoreVisibleSnapshot:x,emitEvent:O,enqueue:_,dispose:L,isDisposed:V}}function ge(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}import{validateExternalContext as ht}from"@manifesto-ai/core";function F(e,t,n){let o=yt(t===void 0?{}:t,n),a=ht(e,o);if(!a.valid){let y=a.errors.map(i=>i.path?`${i.path}: ${i.message}`:i.message).join("; ");throw new b("INVALID_CONTEXT",`Invalid context for ${n}: ${y}`)}return o}function ee(e,t,n,o){return n===void 0?t:F(e,n,o)}function yt(e,t){return ke(e)||k(t,[],"Context must be a plain JSON object"),Object.freeze(Oe(e,t,[],new WeakSet))}function je(e,t,n,o){if(e===null)return null;switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isFinite(e)?e:k(t,n,"Context numbers must be finite");case"undefined":return k(t,n,"Context must not contain undefined");case"function":return k(t,n,"Context must not contain functions");case"symbol":return k(t,n,"Context must not contain symbols");case"bigint":return k(t,n,"Context must not contain bigint values");case"object":break}if(Array.isArray(e)){o.has(e)&&k(t,n,"Context must not contain cycles"),o.add(e),ve(e,t,n),we(e,t,n);let y=[];for(let i=0;i<e.length;i+=1)Object.hasOwn(e,i)||k(t,[...n,i],"Context arrays must not contain holes"),y.push(je(e[i],t,[...n,i],o));return o.delete(e),Object.freeze(y)}ke(e)||k(t,n,"Context objects must be plain JSON objects"),o.has(e)&&k(t,n,"Context must not contain cycles"),o.add(e);let a=Oe(e,t,n,o);return o.delete(e),Object.freeze(a)}function Oe(e,t,n,o){ve(e,t,n),we(e,t,n);let a=Object.create(null);for(let[y,i]of Object.entries(e))a[y]=je(i,t,[...n,y],o);return a}function ke(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ve(e,t,n){for(let[o,a]of Object.entries(Object.getOwnPropertyDescriptors(e)))(a.get||a.set)&&k(t,[...n,o],"Context must not contain getters or setters")}function we(e,t,n){Object.getOwnPropertySymbols(e).length>0&&k(t,n,"Context must not contain symbol keys")}function k(e,t,n){let o=t.length===0?"$context":`$context.${t.map(String).join(".")}`;throw new b("INVALID_CONTEXT",`Invalid context for ${e} at ${o}: ${n}`)}var Et=new Set(["then","constructor","prototype","__proto__"]);function Rt(e){if(e.params)return e.params;let t=e.input;return!t||t.type!=="object"||!t.fields?[]:Object.keys(t.fields)}function It(e){return typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"}function gt({schema:e,projectionPlan:t,actionAnnotations:n,host:o,hostContextProvider:a,MEL:y,createIntent:i,initialContext:r}){let l=y,p=o.getSnapshot();if(!p)throw new b("SCHEMA_ERROR","Host failed to initialize its genesis snapshot");function c(s){return j(Y(s,t))}function h(s){let f=H({...s,computed:{}});if(f)throw new b("SNAPSHOT_REHYDRATION_FAILED",`Failed to rehydrate restored snapshot JSON values: ${f.path}: ${f.reason}`);let R=St(e,s);if(Ct(R))throw new b("SNAPSHOT_REHYDRATION_FAILED",`Failed to rehydrate restored snapshot computed values: ${R.error.message}`,{cause:R.error});let w={...s,computed:R.value},M=H(w);if(M)throw new b("SNAPSHOT_REHYDRATION_FAILED",`Failed to rehydrate restored snapshot JSON values: ${M.path}: ${M.reason}`);return w}let C=Ie({host:o,initialCanonicalSnapshot:p,projectSnapshotFromCanonical:c}),{subscribe:A,on:T,getSnapshot:g,getCanonicalSnapshot:x,getVisibleCoreSnapshot:O,setVisibleSnapshot:_,restoreVisibleSnapshot:L,emitEvent:V,enqueue:S,dispose:m,isDisposed:u}=C,d=Q(xt(e)),I=Object.keys(e.actions);jt(I);let E=F(e,r,"createManifesto"),ne=Object.freeze(Object.fromEntries(I.map(s=>{let f=e.actions[s],w=l.actions[s]?.[X],M=Object.freeze(Array.isArray(w)?[...w]:Rt(f)),de=w===null?1:M.length,Je=f.input?.required===!1?0:de;return[s,Object.freeze({name:s,params:M,publicArity:de,requiredArity:Je,input:f.input,...f.inputType!==void 0?{inputType:f.inputType}:{},description:f.description,...n[s]!==void 0?{annotations:n[s]}:{},hasDispatchableGate:f.dispatchable!==void 0})]}))),Me=Object.freeze(I.map(s=>ne[s]));function oe(s,f){return Tt(e,s,String(f))}function ae(s,f){return At(e,s,f)}function D(s){let f=bt(e,s);return f.kind==="error"?Object.freeze([]):Object.freeze([...f.actions])}let $=be({getAvailableActionsFor:D,projectSnapshotFromCanonical:c});function Pe(){return D(x())}let _e=(s=>s!==void 0?ne[String(s)]:Me);function G(s,f){let R=oe(s,f);return R.kind==="ok"&&R.available}function Le(s){return G(x(),s)}function K(s,f){let R=ae(s,f);return R.kind==="ok"&&R.dispatchable}let Ve=((s,...f)=>K(x(),i(s,...f)));function re(s){return s.intentId&&s.intentId.length>0?s:{...s,intentId:ge()}}async function ze(s,f){return o.dispatch(s,f)}function Be(){return E}function He(s){return E=F(e,s,"injectContext"),E}function Fe(s){let f=s(E);if(It(f))throw new b("INVALID_CONTEXT","updateContext() updater must return a synchronous JSON context value");return E=F(e,f,"updateContext"),E}function ie(s){return ee(e,E,s,"transition")}function se(s,f){let R=f===void 0?E:ee(e,E,f,"transition");return a.createFrozenContext(s.intentId,R)}let J=null,v=Ae({schema:e,ensureIntentId:re,getAvailableActionsFor:D,isActionAvailableFor:G,isIntentDispatchableFor:K,evaluateActionAvailabilityFor:oe,evaluateIntentDispatchabilityFor:ae,projectSnapshotFromCanonical:c,getSimulateSync:()=>{if(!J)throw new b("SCHEMA_ERROR","Runtime simulation surface is not initialized");return J}}),ce=Re({schema:e,hostContextProvider:a,evaluateIntentLegalityFor:v.evaluateIntentLegalityFor});J=ce.simulateSync;let le=Ce({setVisibleSnapshot:_,restoreVisibleSnapshot:L,getCanonicalSnapshot:x}),ue=v.getIntentBlockersFor,Ge=((s,...f)=>ue(x(),i(s,...f))),q=(s,f,R)=>{let w=R?.context??se(f,R?.externalContext??ie());return ce.simulateSync(s,f,{context:w})};function Ke(s){let f=c(s.snapshot);return Object.freeze({snapshot:f,changedPaths:B(g(),f),newAvailableActions:D(s.snapshot),requirements:s.requirements,status:s.status,diagnostics:s.diagnostics})}let pe=(s=>Ke(q(x(),s))),Ue=((s,...f)=>pe(i(s,...f))),$e=Object.freeze({refs:l,MEL:y,schema:e,createIntent:i,getCanonicalSnapshot:x,projectSnapshot:s=>c(s),simulateSync:(s,f)=>{let R=q(s,f);return Object.freeze({snapshot:R.snapshot,patches:R.patches,requirements:R.requirements,status:R.status,diagnostics:R.diagnostics})},getAvailableActionsFor:D,isActionAvailableFor:G,isIntentDispatchableFor:K,explainIntentFor:v.explainIntentFor});return{schema:e,refs:l,MEL:y,createIntent:i,subscribe:A,on:T,getSnapshot:g,getAvailableActionsFor:D,getAvailableActions:Pe,getIntentBlockersFor:ue,getActionMetadata:_e,isActionAvailableFor:G,isActionAvailable:Le,isIntentDispatchableFor:K,isIntentDispatchable:Ve,getIntentBlockers:Ge,getSchemaGraph(){return d},simulateSync:q,simulate:Ue,simulateIntent:pe,dispose:m,isDisposed:u,getCanonicalSnapshot:x,getVisibleCoreSnapshot:O,rehydrateSnapshot:h,setVisibleSnapshot:le.replaceVisibleSnapshot,restoreVisibleSnapshot:le.restoreVisibleSnapshot,emitEvent:V,enqueue:S,ensureIntentId:re,executeHost:ze,createComputeContext:se,getExternalContext:Be,replaceExternalContext:He,updateExternalContext:Fe,captureExternalContext:ie,validateIntentInputFor:v.validateIntentInputFor,evaluateIntentLegalityFor:v.evaluateIntentLegalityFor,deriveIntentAdmission:v.deriveIntentAdmission,deriveExecutionOutcome:$.deriveExecutionOutcome,classifyExecutionFailure:$.classifyExecutionFailure,createExecutionDiagnostics:$.createExecutionDiagnostics,createUnavailableError:v.createUnavailableError,createNotDispatchableError:v.createNotDispatchableError,rejectInvalidInput:v.rejectInvalidInput,rejectUnavailable:v.rejectUnavailable,rejectNotDispatchable:v.rejectNotDispatchable,[N]:$e}}function jt(e){let t=e.filter(n=>Et.has(n));if(t.length!==0)throw new b("RESERVED_ACTION_NAME",`Action name${t.length===1?"":"s"} ${t.map(n=>`"${n}"`).join(", ")} ${t.length===1?"is":"are"} reserved by the SDK public action namespace`)}function te(e,t){return Object.freeze({path:Object.freeze([]),code:t,message:e.description??t,detail:Object.freeze({layer:e.layer,expression:e.expression})})}function Ot(e,t,n){if(t.failure.kind==="invalid_input"){let a=t.failure;return Object.freeze({ok:!1,action:e,layer:"input",code:"INVALID_INPUT",message:a.error.message,blockers:Object.freeze([])})}if(t.failure.kind==="not_dispatchable"){let a=t.failure;return Object.freeze({ok:!1,action:e,layer:"dispatchability",code:"INTENT_NOT_DISPATCHABLE",message:n??`Action "${e}" is not dispatchable against the current visible snapshot`,blockers:a.blockers.map(y=>te(y,"INTENT_NOT_DISPATCHABLE"))})}let o=t.failure;return Object.freeze({ok:!1,action:e,layer:"availability",code:"ACTION_UNAVAILABLE",message:n??`Action "${e}" is unavailable against the current visible snapshot`,blockers:(o.blockers??[]).map(a=>te(a,"ACTION_UNAVAILABLE"))})}function En(e,t,n){Object.defineProperty(e,U,{enumerable:!1,configurable:!1,writable:!1,value:t});let o=n??Ne(e)??{activated:!1};return Ne(e)||Object.defineProperty(e,z,{enumerable:!1,configurable:!1,writable:!1,value:o}),e}function Rn(e){let n=e[U];if(typeof n!="function")throw new b("SCHEMA_ERROR","ComposableManifesto is missing its runtime kernel factory");return n}function In(e,t){return Object.defineProperty(e,N,{enumerable:!1,configurable:!1,writable:!1,value:t[N]}),e}function gn(e){let n=e[N];if(!n)throw new b("SCHEMA_ERROR","Activated runtime is missing its extension kernel");return n}function De(e){let n=e[z];if(!n)throw new b("SCHEMA_ERROR","ComposableManifesto is missing its activation state");return n}function jn(e){if(De(e).activated)throw new W}function On(e){let t=De(e);if(t.activated)throw new W;t.activated=!0}function Ne(e){return e[z]??null}export{X as a,Qe as b,N as c,kt as d,vt as e,j as f,B as g,Ce as h,ge as i,gt as j,te as k,Ot as l,En as m,Rn as n,In as o,gn as p,De as q,jn as r,On as s};
@@ -1 +1 @@
1
- import{f as m,p as c}from"./chunk-DPFMD6LR.js";import{a as S}from"./chunk-TG2UPPZN.js";function p(n){return n==="pending"||n==="halted"||n==="error"}function d(n){return n.__kind==="ActionRef"}function l(n){return Object.freeze([...n])}function u(n,e,t){return Object.freeze(t?[]:n.getAvailableActionsFor(e).map(i=>n.refs.actions[i]))}function y(n,e,t,i,s){let a=p(s);return Object.freeze({intent:m(n),snapshot:e.projectSnapshot(t),canonicalSnapshot:t,availableActions:u(e,t,a),requirements:l(i),status:s,isTerminal:a})}function T(n,e){return Object.freeze({snapshot:e.snapshot,canonicalSnapshot:e.canonicalSnapshot,depth:e.depth,trajectory:e.trajectory,availableActions:e.availableActions,requirements:e.requirements,status:e.status,isTerminal:e.isTerminal,finish(){return e},next(i,...s){if(e.isTerminal)throw new S("SIMULATION_SESSION_TERMINAL","SimulationSession.next() cannot advance a terminal session");let a=d(i)?n.createIntent(i,...s):i,r=n.simulateSync(e.canonicalSnapshot,a),o=y(a,n,r.snapshot,r.requirements,r.status),f=Object.freeze({snapshot:o.snapshot,canonicalSnapshot:r.snapshot,depth:e.depth+1,trajectory:l([...e.trajectory,o]),availableActions:o.availableActions,requirements:o.requirements,status:o.status,isTerminal:o.isTerminal});return T(n,f)}})}function h(n){let e=c(n),t=e.getCanonicalSnapshot(),i=t.system.status,s=p(i);return T(e,Object.freeze({snapshot:e.projectSnapshot(t),canonicalSnapshot:t,depth:0,trajectory:Object.freeze([]),availableActions:u(e,t,s),requirements:l(t.system.pendingRequirements),status:i,isTerminal:s}))}function v(n){return c(n)}export{h as createSimulationSession,v as getExtensionKernel};
1
+ import{f as m,p as c}from"./chunk-L7HPZ7ZD.js";import{a as S}from"./chunk-TG2UPPZN.js";function p(n){return n==="pending"||n==="halted"||n==="error"}function d(n){return n.__kind==="ActionRef"}function l(n){return Object.freeze([...n])}function u(n,e,t){return Object.freeze(t?[]:n.getAvailableActionsFor(e).map(i=>n.refs.actions[i]))}function y(n,e,t,i,s){let a=p(s);return Object.freeze({intent:m(n),snapshot:e.projectSnapshot(t),canonicalSnapshot:t,availableActions:u(e,t,a),requirements:l(i),status:s,isTerminal:a})}function T(n,e){return Object.freeze({snapshot:e.snapshot,canonicalSnapshot:e.canonicalSnapshot,depth:e.depth,trajectory:e.trajectory,availableActions:e.availableActions,requirements:e.requirements,status:e.status,isTerminal:e.isTerminal,finish(){return e},next(i,...s){if(e.isTerminal)throw new S("SIMULATION_SESSION_TERMINAL","SimulationSession.next() cannot advance a terminal session");let a=d(i)?n.createIntent(i,...s):i,r=n.simulateSync(e.canonicalSnapshot,a),o=y(a,n,r.snapshot,r.requirements,r.status),f=Object.freeze({snapshot:o.snapshot,canonicalSnapshot:r.snapshot,depth:e.depth+1,trajectory:l([...e.trajectory,o]),availableActions:o.availableActions,requirements:o.requirements,status:o.status,isTerminal:o.isTerminal});return T(n,f)}})}function h(n){let e=c(n),t=e.getCanonicalSnapshot(),i=t.system.status,s=p(i);return T(e,Object.freeze({snapshot:e.projectSnapshot(t),canonicalSnapshot:t,depth:0,trajectory:Object.freeze([]),availableActions:u(e,t,s),requirements:l(t.system.pendingRequirements),status:i,isTerminal:s}))}function v(n){return c(n)}export{h as createSimulationSession,v as getExtensionKernel};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as _}from"./chunk-OW22XF26.js";import{a as m,b as p,d as D,e as T,f as I,i as v,j as A,m as k,s as w}from"./chunk-DPFMD6LR.js";import{a as c,b as h,c as y,d as G,e as F,f as K}from"./chunk-TG2UPPZN.js";import{createHostContextProvider as W,createHost as U,defaultRuntime as J}from"@manifesto-ai/host";import{createSnapshot as X,evaluateComputed as Y,extractDefaults as q,isOk as Q}from"@manifesto-ai/core";function S(e,t,n){let o=J,a=W(o),r=X(q(e.state),e.hash,a.createInitialContext()),i=Y(e,r),s=U(e,{initialSnapshot:Q(i)?{...r,computed:i.value}:r,runtime:o});for(let[l,d]of Object.entries(n)){let u=async(pe,$,z)=>await d($,{snapshot:I(T(z.snapshot,t))});s.registerEffect(l,u)}return{host:s,contextProvider:a}}import{createIntent as Z}from"@manifesto-ai/core";function b(){return(e,...t)=>{let n=e,o=v(),a=ee(n,t);return Z(String(e.name),a,o)}}function ee(e,t){let n=Object.hasOwn(e,m)?e[m]:[];if(t.length!==0){if(n===null){if(t.length===1&&f(t[0]))return t[0];throw new c("INVALID_INTENT_ARGS",`Action "${String(e.name)}" requires a single object argument because positional parameter metadata is unavailable`)}if(n.length===0)throw new c("INVALID_INTENT_ARGS",`Action "${String(e.name)}" does not accept input`);return n.length===1&&t.length===1&&f(t[0])&&e[p]?{[n[0]??"arg0"]:t[0]}:n.length===1&&t.length===1&&te(t[0],n[0])||t.length===1&&f(t[0])&&n.length>1?t[0]:Object.fromEntries(t.map((o,a)=>[n[a]??`arg${a}`,o]))}}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function te(e,t){if(!t||!f(e))return!1;let n=Object.keys(e);return n.length===1&&n[0]===t}import{compileMelModule as ne,parse as oe,tokenize as ae}from"@manifesto-ai/compiler";function L(e){let t=ne(e,{mode:"module"});if(t.errors.length>0){let o=t.errors.map(a=>{let r=a.location;if(!r||r.start.line===0&&r.start.column===0)return`[${a.code}] ${a.message}`;let i=`[${a.code}] ${a.message} (${r.start.line}:${r.start.column})`,s=e.split(`
1
+ import{a as _}from"./chunk-A3JV6JTS.js";import{a as m,b as p,d as D,e as T,f as I,i as v,j as A,m as k,s as w}from"./chunk-L7HPZ7ZD.js";import{a as c,b as h,c as y,d as G,e as F,f as K}from"./chunk-TG2UPPZN.js";import{createHostContextProvider as W,createHost as U,defaultRuntime as J}from"@manifesto-ai/host";import{createSnapshot as X,evaluateComputed as Y,extractDefaults as q,isOk as Q}from"@manifesto-ai/core";function S(e,t,n){let o=J,a=W(o),r=X(q(e.state),e.hash,a.createInitialContext()),i=Y(e,r),s=U(e,{initialSnapshot:Q(i)?{...r,computed:i.value}:r,runtime:o});for(let[l,d]of Object.entries(n)){let u=async(pe,$,z)=>await d($,{snapshot:I(T(z.snapshot,t))});s.registerEffect(l,u)}return{host:s,contextProvider:a}}import{createIntent as Z}from"@manifesto-ai/core";function b(){return(e,...t)=>{let n=e,o=v(),a=ee(n,t);return Z(String(e.name),a,o)}}function ee(e,t){let n=Object.hasOwn(e,m)?e[m]:[];if(t.length!==0){if(n===null){if(t.length===1&&f(t[0]))return t[0];throw new c("INVALID_INTENT_ARGS",`Action "${String(e.name)}" requires a single object argument because positional parameter metadata is unavailable`)}if(n.length===0)throw new c("INVALID_INTENT_ARGS",`Action "${String(e.name)}" does not accept input`);return n.length===1&&t.length===1&&f(t[0])&&e[p]?{[n[0]??"arg0"]:t[0]}:n.length===1&&t.length===1&&te(t[0],n[0])||t.length===1&&f(t[0])&&n.length>1?t[0]:Object.fromEntries(t.map((o,a)=>[n[a]??`arg${a}`,o]))}}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function te(e,t){if(!t||!f(e))return!1;let n=Object.keys(e);return n.length===1&&n[0]===t}import{compileMelModule as ne,parse as oe,tokenize as ae}from"@manifesto-ai/compiler";function L(e){let t=ne(e,{mode:"module"});if(t.errors.length>0){let o=t.errors.map(a=>{let r=a.location;if(!r||r.start.line===0&&r.start.column===0)return`[${a.code}] ${a.message}`;let i=`[${a.code}] ${a.message} (${r.start.line}:${r.start.column})`,s=e.split(`
2
2
  `)[r.start.line-1];if(!s)return i;let l=String(r.start.line).padStart(4," "),d=Math.max(1,r.end.line===r.start.line?Math.min(r.end.column-r.start.column,Math.max(1,s.length-r.start.column+1)):1),u=" ".repeat(l.length+3+r.start.column-1);return`${i}
3
3
  ${l} | ${s}
4
4
  ${u}${"^".repeat(d)}`}).join(`
package/dist/provider.js CHANGED
@@ -1 +1 @@
1
- import{a as s}from"./chunk-OW22XF26.js";import{j as e,k as t,l as a,m as n,n as o,o as r,q as i,r as l,s as m}from"./chunk-DPFMD6LR.js";import"./chunk-TG2UPPZN.js";export{m as activateComposable,l as assertComposableNotActivated,r as attachExtensionKernel,n as attachRuntimeKernelFactory,s as createBaseRuntimeInstance,e as createRuntimeKernel,i as getActivationState,o as getRuntimeKernelFactory,a as mapBlockedAdmission,t as toBlocker};
1
+ import{a as s}from"./chunk-A3JV6JTS.js";import{j as e,k as t,l as a,m as n,n as o,o as r,q as i,r as l,s as m}from"./chunk-L7HPZ7ZD.js";import"./chunk-TG2UPPZN.js";export{m as activateComposable,l as assertComposableNotActivated,r as attachExtensionKernel,n as attachRuntimeKernelFactory,s as createBaseRuntimeInstance,e as createRuntimeKernel,i as getActivationState,o as getRuntimeKernelFactory,a as mapBlockedAdmission,t as toBlocker};
@@ -0,0 +1,7 @@
1
+ import { type JsonValueViolation, type Snapshot as CoreSnapshot } from "@manifesto-ai/core";
2
+ /**
3
+ * Snapshot `input` is transient and current genesis snapshots use
4
+ * `undefined`. Validate it only when a restore payload actually carries a
5
+ * value; persisted domain/system channels must always stay JSON-compatible.
6
+ */
7
+ export declare function findCanonicalSnapshotValueViolation(snapshot: CoreSnapshot): JsonValueViolation | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifesto-ai/sdk",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Manifesto SDK - Activation-first public API for the base runtime",
5
5
  "author": "eggplantiny <eggplantiny@gmail.com>",
6
6
  "license": "MIT",
@@ -47,20 +47,20 @@
47
47
  "dist"
48
48
  ],
49
49
  "dependencies": {
50
- "@manifesto-ai/compiler": "5.0.1",
51
- "@manifesto-ai/host": "5.0.1",
52
- "@manifesto-ai/core": "5.1.0"
50
+ "@manifesto-ai/compiler": "5.0.2",
51
+ "@manifesto-ai/core": "5.1.1",
52
+ "@manifesto-ai/host": "5.0.2"
53
53
  },
54
54
  "devDependencies": {
55
- "typescript": "^5.9.3",
56
- "vite": "^8.0.8",
57
- "vitest": "^4.1.4"
55
+ "typescript": "^6.0.3",
56
+ "vite": "^8.0.16",
57
+ "vitest": "^4.1.9"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "rm -rf dist && tsup && tsc -p tsconfig.build.json --emitDeclarationOnly --declarationMap false --outDir dist",
61
61
  "dev": "tsc --watch",
62
62
  "clean": "rm -rf dist",
63
- "lint": "node ../../node_modules/@biomejs/biome/bin/biome check src",
63
+ "lint": "node ../../scripts/run-biome.mjs check src",
64
64
  "test": "pnpm run test:runtime && pnpm run test:types",
65
65
  "test:runtime": "node ../../scripts/run-vitest.mjs run",
66
66
  "test:types": "node ../../scripts/run-tsc.mjs -p tsconfig.types.json --noEmit",
@@ -1 +0,0 @@
1
- import{a as C,e as q}from"./chunk-TG2UPPZN.js";import{evaluateComputed as ft,evaluateActionAvailability as mt,evaluateAvailableActions as ht,evaluateIntentDispatchability as yt,isErr as St}from"@manifesto-ai/core";import{extractSchemaGraph as bt}from"@manifesto-ai/compiler";function gt(e){return{visibleComputedKeys:Object.keys(e.computed.fields)}}function J(e,t){return{state:$e(e.state),computed:qe(e.computed,t),system:{status:e.system.status,lastError:e.system.lastError},meta:{schemaHash:e.meta.schemaHash}}}function jt(e,t){return J(e,t)}function I(e){return me(structuredClone(e))}function fe(e,t){return Je(e,t)}function $e(e){return structuredClone(e)}function qe(e,t){let n={};for(let o of t.visibleComputedKeys)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return structuredClone(n)}function Je(e,t){return D(e,t,new WeakMap)}function D(e,t,n){if(Object.is(e,t))return!0;if(typeof e!=typeof t)return!1;if(e===null||t===null)return e===t;if(typeof e!="object"||typeof t!="object")return!1;let o=e,a=t,y=Object.prototype.toString.call(o),i=Object.prototype.toString.call(a);if(y!==i)return!1;let r=n.get(o);if(r?.has(a))return!0;if(r||(r=new WeakSet,n.set(o,r)),r.add(a),Array.isArray(o)&&Array.isArray(a)){if(o.length!==a.length)return!1;for(let c=0;c<o.length;c+=1){let h=Object.prototype.hasOwnProperty.call(o,c),x=Object.prototype.hasOwnProperty.call(a,c);if(h!==x||h&&!D(o[c],a[c],n))return!1}return!0}if(o instanceof Date&&a instanceof Date)return o.getTime()===a.getTime();if(o instanceof RegExp&&a instanceof RegExp)return o.source===a.source&&o.flags===a.flags;if(ArrayBuffer.isView(o)&&ArrayBuffer.isView(a)){if(o.constructor!==a.constructor||o.byteLength!==a.byteLength)return!1;let c=new Uint8Array(o.buffer,o.byteOffset,o.byteLength),h=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return c.every((x,T)=>x===h[T])}if(o instanceof ArrayBuffer&&a instanceof ArrayBuffer){if(o.byteLength!==a.byteLength)return!1;let c=new Uint8Array(o),h=new Uint8Array(a);return c.every((x,T)=>x===h[T])}if(o instanceof Map&&a instanceof Map){if(o.size!==a.size)return!1;let c=Array.from(o.entries()),h=Array.from(a.entries());return c.every(([x,T],b)=>{let g=h[b];if(!g)return!1;let[A,k]=g;return D(x,A,n)&&D(T,k,n)})}if(o instanceof Set&&a instanceof Set){if(o.size!==a.size)return!1;let c=Array.from(o.values()),h=Array.from(a.values());return c.every((x,T)=>D(x,h[T],n))}let l=ue(o),u=ue(a);if(l.length!==u.length)return!1;for(let c=0;c<l.length;c+=1){let h=l[c],x=u[c];if(h!==x)return!1;let T=o[h],b=a[x];if(!D(T,b,n))return!1}return!0}function ue(e){return Object.keys(e).filter(t=>e[t]!==void 0).sort()}function me(e,t=new WeakSet){if(e==null||typeof e!="object")return e;if(de(e))return he(e);let n=e;if(t.has(n)||Object.isFrozen(e))return e;t.add(n);for(let o of Reflect.ownKeys(n)){let a=n[o];if(de(a)){We(n,o,a);continue}me(a,t)}return Object.freeze(e)}function de(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)}function he(e){return structuredClone(e)}function We(e,t,n){let o=Object.getOwnPropertyDescriptor(e,t);!o||!("value"in o)||Object.defineProperty(e,t,{enumerable:o.enumerable??!0,configurable:!1,get(){return he(n)}})}var W=Symbol("manifesto-sdk.action-param-names"),Xe=Symbol("manifesto-sdk.action-single-param-object-value"),F=Symbol("manifesto-sdk.runtime-kernel-factory"),z=Symbol("manifesto-sdk.activation-state"),w=Symbol("manifesto-sdk.extension-kernel");var Ye=/^(state|computed|action):.+$/;function X(e){let t=new Set(e.nodes.map(r=>r.id)),n=new Map,o=new Map,a=(r,l,u)=>{let c=r.get(l);if(c){c.add(u);return}r.set(l,new Set([u]))};for(let r of e.edges)a(n,r.from,r.to),a(o,r.to,r.from);let y=r=>{let l=Object.freeze({nodes:Object.freeze(e.nodes.filter(u=>r.has(u.id))),edges:Object.freeze(e.edges.filter(u=>r.has(u.from)&&r.has(u.to)))});return X(l)},i=(r,l)=>{let u=Qe(r,t),c=[u],h=new Set([u]),x=l==="incoming"?o:n;for(;c.length>0;){let T=c.shift();if(T)for(let b of x.get(T)??[])h.has(b)||(h.add(b),c.push(b))}return y(h)};return Object.freeze({nodes:e.nodes,edges:e.edges,traceUp(r){return i(r,"incoming")},traceDown(r){return i(r,"outgoing")}})}function Qe(e,t){if(typeof e=="string"){if(!Ye.test(e))throw new C("SCHEMA_ERROR",'SchemaGraph node id must use "state:<name>", "computed:<name>", or "action:<name>"');if(!t.has(e))throw new C("SCHEMA_ERROR",`Unknown SchemaGraph node id "${e}"`);return e}let n;switch(e.__kind){case"ActionRef":n=`action:${String(e.name)}`;break;case"FieldRef":n=`state:${e.name}`;break;case"ComputedRef":n=`computed:${e.name}`;break;default:throw new C("SCHEMA_ERROR","Unsupported SchemaGraph ref lookup target")}if(!t.has(n))throw new C("SCHEMA_ERROR",`SchemaGraph node "${n}" is not part of the projected graph`);return n}import{validateIntentInput as tt}from"@manifesto-ai/core";function Se({getAvailableActionsFor:e,projectSnapshotFromCanonical:t}){function n(i,r){let l=e(i),u=e(r),c=Object.freeze(u.filter(x=>!l.includes(x))),h=Object.freeze(l.filter(x=>!u.includes(x)));return Object.freeze({before:l,after:u,unlocked:c,locked:h})}function o(i,r){let l=I(i),u=I(r),c=t(l),h=t(u);return Object.freeze({projected:Object.freeze({beforeSnapshot:c,afterSnapshot:h,changedPaths:B(c,h),availability:n(l,u)}),canonical:Object.freeze({beforeCanonicalSnapshot:l,afterCanonicalSnapshot:u,pendingRequirements:u.system.pendingRequirements,status:u.system.status})})}function a(i,r){let l=et(i),u=l;return Object.freeze({message:l.message,...typeof u.code=="string"?{code:u.code}:{},...typeof l.name=="string"?{name:l.name}:{},stage:r})}function y(i){return Object.freeze({hostTraces:I(i.traces)})}return Object.freeze({deriveExecutionOutcome:o,classifyExecutionFailure:a,createExecutionDiagnostics:y})}function B(e,t){let n=new Map,o=new WeakMap,a=(i,r)=>{let l=Ze(i);n.set(l,Object.freeze({path:Object.freeze([...i]),kind:r}))},y=(i,r,l)=>{if(Object.is(i,r))return;if(i===null||r===null){a(l,"changed");return}if(typeof i!="object"||typeof r!="object"){a(l,"changed");return}let u=i,c=r,h=o.get(u);if(h?.has(c))return;if(h?h.add(c):o.set(u,new WeakSet([c])),Array.isArray(i)||Array.isArray(r)){if(!Array.isArray(i)||!Array.isArray(r)){a(l,"changed");return}let T=Math.max(i.length,r.length);for(let b=0;b<T;b+=1){let g=Object.prototype.hasOwnProperty.call(i,b),A=Object.prototype.hasOwnProperty.call(r,b),k=[...l,b];if(g!==A){a(k,g?"unset":"set");continue}!g&&!A||y(i[b],r[b],k)}return}if(!ye(i)||!ye(r)){a(l,"changed");return}let x=new Set([...Object.keys(i),...Object.keys(r)]);for(let T of[...x].sort()){let b=Object.prototype.hasOwnProperty.call(i,T),g=Object.prototype.hasOwnProperty.call(r,T),A=[...l,T];if(b!==g){a(A,b?"unset":"set");continue}y(i[T],r[T],A)}};return y(e.state,t.state,["state"]),y(e.computed,t.computed,["computed"]),y(e.system,t.system,["system"]),y(e.meta,t.meta,["meta"]),Object.freeze([...n.entries()].sort(([i],[r])=>i.localeCompare(r)).map(([,i])=>i))}function ye(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ze(e){return e.map(t=>typeof t=="number"?`[${t}]`:t).join(".")}function et(e){return e instanceof Error?e:new Error(String(e))}function be({schema:e,ensureIntentId:t,getAvailableActionsFor:n,isActionAvailableFor:o,evaluateActionAvailabilityFor:a,evaluateIntentDispatchabilityFor:y,projectSnapshotFromCanonical:i,getSimulateSync:r}){function l(S,m,p){return Object.freeze({layer:S,expression:m,evaluatedResult:!1,...p!==void 0?{description:p}:{}})}function u(S,m){let p=m.type,d=e.actions[p];if(!d)return Object.freeze([]);let R=a(S,p);if(R.kind==="error")return Object.freeze(d.available?[l("available",d.available,R.message)]:[]);if(!R.available)return Object.freeze(d.available?[l("available",d.available,d.description)]:[]);let E=y(S,m);return E.kind==="error"?Object.freeze(d.dispatchable?[l("dispatchable",d.dispatchable,E.message)]:[]):E.dispatchable?Object.freeze([]):Object.freeze(d.dispatchable?[l("dispatchable",d.dispatchable,d.description)]:[])}function c(S){return new C("ACTION_UNAVAILABLE",`Action "${S.type}" is unavailable against the current visible snapshot`)}function h(S){return new C("INTENT_NOT_DISPATCHABLE",`Action "${S.type}" is available, but the bound intent is not dispatchable against the current visible snapshot`)}function x(S){return new C("INVALID_INPUT",S)}function T(S,m){let p=tt(e,m);return p?x(p):null}function b(S,m){let p=t(m),d=p.type;if(!o(S,d))return{kind:"unavailable",intent:p,actionName:d};let R=T(S,p);if(R)return{kind:"invalid-input",intent:p,actionName:d,error:R};let E=u(S,p);return E.length>0?{kind:"not-dispatchable",intent:p,actionName:d,blockers:E}:{kind:"admitted",intent:p,actionName:d}}function g(S,m){return m.kind==="unavailable"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"unavailable",blockers:u(S,m.intent)}}):m.kind==="invalid-input"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"invalid_input",error:{code:"INVALID_INPUT",message:m.error.message}}}):m.kind==="not-dispatchable"?Object.freeze({kind:"blocked",actionName:m.actionName,failure:{kind:"not_dispatchable",blockers:m.blockers}}):Object.freeze({kind:"admitted",actionName:m.actionName})}function A(S,m){let p=b(S,m);if(p.kind==="unavailable")return Object.freeze({kind:"blocked",actionName:p.actionName,available:!1,dispatchable:!1,blockers:u(S,p.intent)});if(p.kind==="invalid-input")throw p.error;if(p.kind==="not-dispatchable")return Object.freeze({kind:"blocked",actionName:p.actionName,available:!0,dispatchable:!1,blockers:p.blockers});let d=r()(S,p.intent),R=i(S),E=i(d.snapshot);return Object.freeze({kind:"admitted",actionName:p.actionName,available:!0,dispatchable:!0,status:d.status,requirements:d.requirements,canonicalSnapshot:d.snapshot,snapshot:E,newAvailableActions:n(d.snapshot),changedPaths:B(R,E)})}function k(S,m){throw m}function P(S){return k(S,c(S))}function M(S,m){return k(S,x(m))}function _(S){return k(S,h(S))}return Object.freeze({getIntentBlockersFor:u,validateIntentInputFor:T,evaluateIntentLegalityFor:b,deriveIntentAdmission:g,explainIntentFor:A,createUnavailableError:c,createNotDispatchableError:h,rejectInvalidInput:M,rejectUnavailable:P,rejectNotDispatchable:_})}function Te({setVisibleSnapshot:e,restoreVisibleSnapshot:t,getCanonicalSnapshot:n}){function o(i,r){return e(i,r)}function a(i){let r=o(i);return Object.freeze({publishedSnapshot:r,publishedCanonicalSnapshot:n()})}function y(i){let r=o(i);return Object.freeze({publishedSnapshot:r,publishedCanonicalSnapshot:n()})}return Object.freeze({replaceVisibleSnapshot:o,restoreVisibleSnapshot:t,publishCompletedHostResult:a,publishFailedHostResult:y})}import{apply as nt,applyNamespaceDeltas as xe,applySystemDelta as ot,computeSync as at}from"@manifesto-ai/core";import{getHostState as rt}from"@manifesto-ai/host/tooling";function Ce(e,t){return{...e,timestamp:t,children:e.children.map(n=>Ce(n,t))}}function it(e){let t={};function n(o){t[o.id]=o,o.children.forEach(n)}return n(e),t}function st(e,t){let n=Ce(e.root,t);return{...e,duration:0,root:n,nodes:it(n)}}function Ae({schema:e,hostContextProvider:t,evaluateIntentLegalityFor:n}){function o(r,l){let c=rt(r)?.intentSlots??{},h=l.input===void 0?{type:l.type}:{type:l.type,input:l.input};return xe(r,[{namespace:"host",patches:[{op:"set",path:[{kind:"prop",name:"intentSlots"}],value:{...c,[l.intentId]:h}}]}])}function a(r){return new C("ACTION_UNAVAILABLE",`Action "${r.type}" is unavailable against the provided canonical snapshot`)}function y(r){return new C("INTENT_NOT_DISPATCHABLE",`Action "${r.type}" is available, but the bound intent is not dispatchable against the provided canonical snapshot`)}return Object.freeze({withHostIntentSlot:o,createSimulationUnavailableError:a,createSimulationNotDispatchableError:y,simulateSync:(r,l,u)=>{let c=n(r,l);if(c.kind==="unavailable")throw a(c.intent);if(c.kind==="invalid-input")throw c.error;if(c.kind==="not-dispatchable")throw y(c.intent);let h=c.intent,x=u?.context??t.createFrozenContext(h.intentId,u?.externalContext),T=o(structuredClone(r),h),b=at(e,T,h,x),g=nt(e,T,b.patches),A=xe(g,b.namespaceDelta??[]),k=ot(A,b.systemDelta);return Object.freeze({snapshot:I(k),patches:I(b.patches),systemDelta:I(b.systemDelta),status:b.status,requirements:I(b.systemDelta.addRequirements??[]),diagnostics:Object.freeze({trace:I(st(b.trace,r.meta.timestamp))})})}})}var ct=new Set(["state","computed","system","input","meta","namespaces"]),lt=["state","system","meta"];function pt(e){if(e===null||typeof e!="object"||Array.isArray(e))throw new C("INVALID_SNAPSHOT_SHAPE","Visible snapshot must be a canonical snapshot object");let t=e,n=Object.keys(t).filter(o=>!ct.has(o));if(n.length>0){let o=n.includes("data")?' Domain state lives under "state" since v5; the v4 "data" key was renamed.':"";throw new C("INVALID_SNAPSHOT_SHAPE",`Visible snapshot has unknown top-level key(s): ${n.join(", ")}.${o} Expected only: state, computed, system, input, meta, namespaces.`)}for(let o of lt){let a=t[o];if(a===null||typeof a!="object"||Array.isArray(a))throw new C("INVALID_SNAPSHOT_SHAPE",`Visible snapshot is missing the required "${o}" object`)}}function Ee({host:e,initialCanonicalSnapshot:t,projectSnapshotFromCanonical:n}){let o=structuredClone(t),a=n(o),y=I(o),i=Promise.resolve(),r=!1,l=new Set,u=new Map;function c(m,p){if(r)return()=>{};let d,R=!1;try{d=m(a),R=!0}catch{d=void 0,R=!1}let E={selector:m,listener:p,lastValue:d,initialized:R};return l.add(E),()=>{l.delete(E)}}function h(m,p){if(r)return()=>{};let d=u.get(m);return d||(d=new Set,u.set(m,d)),d.add(p),()=>{d?.delete(p)}}function x(){return a}function T(){return y}function b(){return structuredClone(o)}function g(m,p){pt(m),o=structuredClone(m),e.reset(structuredClone(o)),y=I(o);let d=n(o),R=!fe(d,a);return R&&(a=d),p?.notify!==!1&&R&&S(a),a}function A(){e.reset(structuredClone(o))}function k(m,p){let d=u.get(m);if(d)for(let R of d)try{R(p)}catch{}}function P(m){let p=i.catch(()=>{}).then(m);return i=p.then(()=>{},()=>{}),p}function M(){r||(r=!0,l.clear(),u.clear())}function _(){return r}function S(m){for(let p of l){let d;try{d=p.selector(m)}catch{continue}if(!(p.initialized&&Object.is(p.lastValue,d))){p.lastValue=d,p.initialized=!0;try{p.listener(d)}catch{}}}}return{subscribe:c,on:h,getSnapshot:x,getCanonicalSnapshot:T,getVisibleCoreSnapshot:b,setVisibleSnapshot:g,restoreVisibleSnapshot:A,emitEvent:k,enqueue:P,dispose:M,isDisposed:_}}function Re(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}import{validateExternalContext as ut}from"@manifesto-ai/core";function V(e,t,n){let o=dt(t===void 0?{}:t,n),a=ut(e,o);if(!a.valid){let y=a.errors.map(i=>i.path?`${i.path}: ${i.message}`:i.message).join("; ");throw new C("INVALID_CONTEXT",`Invalid context for ${n}: ${y}`)}return o}function Y(e,t,n,o){return n===void 0?t:V(e,n,o)}function dt(e,t){return Ie(e)||O(t,[],"Context must be a plain JSON object"),Object.freeze(je(e,t,[],new WeakSet))}function ge(e,t,n,o){if(e===null)return null;switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isFinite(e)?e:O(t,n,"Context numbers must be finite");case"undefined":return O(t,n,"Context must not contain undefined");case"function":return O(t,n,"Context must not contain functions");case"symbol":return O(t,n,"Context must not contain symbols");case"bigint":return O(t,n,"Context must not contain bigint values");case"object":break}if(Array.isArray(e)){o.has(e)&&O(t,n,"Context must not contain cycles"),o.add(e),ke(e,t,n),Oe(e,t,n);let y=[];for(let i=0;i<e.length;i+=1)Object.prototype.hasOwnProperty.call(e,i)||O(t,[...n,i],"Context arrays must not contain holes"),y.push(ge(e[i],t,[...n,i],o));return o.delete(e),Object.freeze(y)}Ie(e)||O(t,n,"Context objects must be plain JSON objects"),o.has(e)&&O(t,n,"Context must not contain cycles"),o.add(e);let a=je(e,t,n,o);return o.delete(e),Object.freeze(a)}function je(e,t,n,o){ke(e,t,n),Oe(e,t,n);let a=Object.create(null);for(let[y,i]of Object.entries(e))a[y]=ge(i,t,[...n,y],o);return a}function Ie(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ke(e,t,n){for(let[o,a]of Object.entries(Object.getOwnPropertyDescriptors(e)))(a.get||a.set)&&O(t,[...n,o],"Context must not contain getters or setters")}function Oe(e,t,n){Object.getOwnPropertySymbols(e).length>0&&O(t,n,"Context must not contain symbol keys")}function O(e,t,n){let o=t.length===0?"$context":`$context.${t.map(String).join(".")}`;throw new C("INVALID_CONTEXT",`Invalid context for ${e} at ${o}: ${n}`)}var Tt=new Set(["then","constructor","prototype","__proto__"]);function xt(e){if(e.params)return e.params;let t=e.input;return!t||t.type!=="object"||!t.fields?[]:Object.keys(t.fields)}function Ct(e){return typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function"}function At({schema:e,projectionPlan:t,actionAnnotations:n,host:o,hostContextProvider:a,MEL:y,createIntent:i,initialContext:r}){let l=y,u=o.getSnapshot();if(!u)throw new C("SCHEMA_ERROR","Host failed to initialize its genesis snapshot");function c(s){return I(J(s,t))}function h(s){let f=ft(e,s);if(St(f))throw new C("SNAPSHOT_REHYDRATION_FAILED",`Failed to rehydrate restored snapshot computed values: ${f.error.message}`,{cause:f.error});return{...s,computed:f.value}}let x=Ee({host:o,initialCanonicalSnapshot:u,projectSnapshotFromCanonical:c}),{subscribe:T,on:b,getSnapshot:g,getCanonicalSnapshot:A,getVisibleCoreSnapshot:k,setVisibleSnapshot:P,restoreVisibleSnapshot:M,emitEvent:_,enqueue:S,dispose:m,isDisposed:p}=x,d=X(bt(e)),R=Object.keys(e.actions);Et(R);let E=V(e,r,"createManifesto"),Z=Object.freeze(Object.fromEntries(R.map(s=>{let f=e.actions[s],L=l.actions[s]?.[W],le=Object.freeze(Array.isArray(L)?[...L]:xt(f)),pe=L===null?1:le.length,Ue=f.input?.required===!1?0:pe;return[s,Object.freeze({name:s,params:le,publicArity:pe,requiredArity:Ue,input:f.input,...f.inputType!==void 0?{inputType:f.inputType}:{},description:f.description,...n[s]!==void 0?{annotations:n[s]}:{},hasDispatchableGate:f.dispatchable!==void 0})]}))),Ne=Object.freeze(R.map(s=>Z[s]));function ee(s,f){return mt(e,s,String(f))}function te(s,f){return yt(e,s,f)}function N(s){let f=ht(e,s);return f.kind==="error"?Object.freeze([]):Object.freeze([...f.actions])}let K=Se({getAvailableActionsFor:N,projectSnapshotFromCanonical:c});function De(){return N(A())}let Pe=(s=>s!==void 0?Z[String(s)]:Ne);function G(s,f){let j=ee(s,f);return j.kind==="ok"&&j.available}function Me(s){return G(A(),s)}function H(s,f){let j=te(s,f);return j.kind==="ok"&&j.dispatchable}let _e=((s,...f)=>H(A(),i(s,...f)));function ne(s){return s.intentId&&s.intentId.length>0?s:{...s,intentId:Re()}}async function Le(s,f){return o.dispatch(s,f)}function ze(){return E}function Be(s){return E=V(e,s,"injectContext"),E}function Ve(s){let f=s(E);if(Ct(f))throw new C("INVALID_CONTEXT","updateContext() updater must return a synchronous JSON context value");return E=V(e,f,"updateContext"),E}function oe(s){return Y(e,E,s,"transition")}function ae(s,f){let j=f===void 0?E:Y(e,E,f,"transition");return a.createFrozenContext(s.intentId,j)}let U=null,v=be({schema:e,ensureIntentId:ne,getAvailableActionsFor:N,isActionAvailableFor:G,isIntentDispatchableFor:H,evaluateActionAvailabilityFor:ee,evaluateIntentDispatchabilityFor:te,projectSnapshotFromCanonical:c,getSimulateSync:()=>{if(!U)throw new C("SCHEMA_ERROR","Runtime simulation surface is not initialized");return U}}),re=Ae({schema:e,hostContextProvider:a,evaluateIntentLegalityFor:v.evaluateIntentLegalityFor});U=re.simulateSync;let ie=Te({setVisibleSnapshot:P,restoreVisibleSnapshot:M,getCanonicalSnapshot:A}),se=v.getIntentBlockersFor,Ge=((s,...f)=>se(A(),i(s,...f))),$=(s,f,j)=>{let L=j?.context??ae(f,j?.externalContext??oe());return re.simulateSync(s,f,{context:L})};function He(s){let f=c(s.snapshot);return Object.freeze({snapshot:f,changedPaths:B(g(),f),newAvailableActions:N(s.snapshot),requirements:s.requirements,status:s.status,diagnostics:s.diagnostics})}let ce=(s=>He($(A(),s))),Fe=((s,...f)=>ce(i(s,...f))),Ke=Object.freeze({refs:l,MEL:y,schema:e,createIntent:i,getCanonicalSnapshot:A,projectSnapshot:s=>c(s),simulateSync:(s,f)=>{let j=$(s,f);return Object.freeze({snapshot:j.snapshot,patches:j.patches,requirements:j.requirements,status:j.status,diagnostics:j.diagnostics})},getAvailableActionsFor:N,isActionAvailableFor:G,isIntentDispatchableFor:H,explainIntentFor:v.explainIntentFor});return{schema:e,refs:l,MEL:y,createIntent:i,subscribe:T,on:b,getSnapshot:g,getAvailableActionsFor:N,getAvailableActions:De,getIntentBlockersFor:se,getActionMetadata:Pe,isActionAvailableFor:G,isActionAvailable:Me,isIntentDispatchableFor:H,isIntentDispatchable:_e,getIntentBlockers:Ge,getSchemaGraph(){return d},simulateSync:$,simulate:Fe,simulateIntent:ce,dispose:m,isDisposed:p,getCanonicalSnapshot:A,getVisibleCoreSnapshot:k,rehydrateSnapshot:h,setVisibleSnapshot:ie.replaceVisibleSnapshot,restoreVisibleSnapshot:ie.restoreVisibleSnapshot,emitEvent:_,enqueue:S,ensureIntentId:ne,executeHost:Le,createComputeContext:ae,getExternalContext:ze,replaceExternalContext:Be,updateExternalContext:Ve,captureExternalContext:oe,validateIntentInputFor:v.validateIntentInputFor,evaluateIntentLegalityFor:v.evaluateIntentLegalityFor,deriveIntentAdmission:v.deriveIntentAdmission,deriveExecutionOutcome:K.deriveExecutionOutcome,classifyExecutionFailure:K.classifyExecutionFailure,createExecutionDiagnostics:K.createExecutionDiagnostics,createUnavailableError:v.createUnavailableError,createNotDispatchableError:v.createNotDispatchableError,rejectInvalidInput:v.rejectInvalidInput,rejectUnavailable:v.rejectUnavailable,rejectNotDispatchable:v.rejectNotDispatchable,[w]:Ke}}function Et(e){let t=e.filter(n=>Tt.has(n));if(t.length!==0)throw new C("RESERVED_ACTION_NAME",`Action name${t.length===1?"":"s"} ${t.map(n=>`"${n}"`).join(", ")} ${t.length===1?"is":"are"} reserved by the SDK public action namespace`)}function Q(e,t){return Object.freeze({path:Object.freeze([]),code:t,message:e.description??t,detail:Object.freeze({layer:e.layer,expression:e.expression})})}function Rt(e,t,n){if(t.failure.kind==="invalid_input"){let a=t.failure;return Object.freeze({ok:!1,action:e,layer:"input",code:"INVALID_INPUT",message:a.error.message,blockers:Object.freeze([])})}if(t.failure.kind==="not_dispatchable"){let a=t.failure;return Object.freeze({ok:!1,action:e,layer:"dispatchability",code:"INTENT_NOT_DISPATCHABLE",message:n??`Action "${e}" is not dispatchable against the current visible snapshot`,blockers:a.blockers.map(y=>Q(y,"INTENT_NOT_DISPATCHABLE"))})}let o=t.failure;return Object.freeze({ok:!1,action:e,layer:"availability",code:"ACTION_UNAVAILABLE",message:n??`Action "${e}" is unavailable against the current visible snapshot`,blockers:(o.blockers??[]).map(a=>Q(a,"ACTION_UNAVAILABLE"))})}function hn(e,t,n){Object.defineProperty(e,F,{enumerable:!1,configurable:!1,writable:!1,value:t});let o=n??ve(e)??{activated:!1};return ve(e)||Object.defineProperty(e,z,{enumerable:!1,configurable:!1,writable:!1,value:o}),e}function yn(e){let n=e[F];if(typeof n!="function")throw new C("SCHEMA_ERROR","ComposableManifesto is missing its runtime kernel factory");return n}function Sn(e,t){return Object.defineProperty(e,w,{enumerable:!1,configurable:!1,writable:!1,value:t[w]}),e}function bn(e){let n=e[w];if(!n)throw new C("SCHEMA_ERROR","Activated runtime is missing its extension kernel");return n}function we(e){let n=e[z];if(!n)throw new C("SCHEMA_ERROR","ComposableManifesto is missing its activation state");return n}function Tn(e){if(we(e).activated)throw new q}function xn(e){let t=we(e);if(t.activated)throw new q;t.activated=!0}function ve(e){return e[z]??null}export{W as a,Xe as b,w as c,gt as d,jt as e,I as f,B as g,Te as h,Re as i,At as j,Q as k,Rt as l,hn as m,yn as n,Sn as o,bn as p,we as q,Tn as r,xn as s};