@manifesto-ai/sdk 3.13.1 → 3.14.0
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/README.md +1 -1
- package/dist/index.js +4 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`@manifesto-ai/sdk` is the default package for applications that start with `createManifesto()`.
|
|
6
6
|
|
|
7
|
-
> **Current Contract Note:** The current SDK contract is the
|
|
7
|
+
> **Current Contract Note:** The current SDK contract is the activation-first model documented in [docs/sdk-SPEC.md](docs/sdk-SPEC.md). It includes typed `createIntent()` object binding, intent explanation reads, `@manifesto-ai/sdk/extensions`, and `createSimulationSession(instance)`.
|
|
8
8
|
|
|
9
9
|
## When to Use It
|
|
10
10
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as y,b,c as H,d as L,e as N,f as B,g as V,h as $,i as F,j as E,k as A,l as G,n as z,r as K}from"./chunk-5BUS6Q4E.js";import{a as
|
|
2
|
-
`)[i.start.line-1];if(!d)return
|
|
1
|
+
import{a as y,b,c as H,d as L,e as N,f as B,g as V,h as $,i as F,j as E,k as A,l as G,n as z,r as K}from"./chunk-5BUS6Q4E.js";import{a as l,b as R,c as j,d as h,e as ne}from"./chunk-BDIXNUQ3.js";async function M(e,t,n,a){let r=e.getCanonicalSnapshot(),i=t.projectSnapshot(r),o=e.evaluateIntentLegalityFor(r,a),d=e.deriveIntentAdmission(r,o);if(o.kind!=="admitted"){let u=d,f=oe(e,o),T=V(e.emitEvent,o.intent,f);return{kind:"rejected",intent:o.intent,admission:u,beforeSnapshot:i,beforeCanonicalSnapshot:r,rejection:T,rejectionError:f}}let c=d,s;try{s=await e.executeHost(o.intent)}catch(u){let f=ae(u);return $(e.emitEvent,o.intent,f),{kind:"failed",intent:o.intent,admission:c,beforeSnapshot:i,beforeCanonicalSnapshot:r,failure:f,errorInfo:e.classifyExecutionFailure(f,"host"),published:!1}}let p=e.createExecutionDiagnostics(s);if(s.status==="error"){let u=s.error??new l("HOST_ERROR","Host dispatch failed"),{publishedSnapshot:f,publishedCanonicalSnapshot:T}=n.publishFailedHostResult(o.intent,u,s.snapshot);return{kind:"failed",intent:o.intent,admission:c,beforeSnapshot:i,beforeCanonicalSnapshot:r,failure:u,errorInfo:e.classifyExecutionFailure(u,"host"),published:!0,diagnostics:p,outcome:e.deriveExecutionOutcome(r,T)}}let{publishedSnapshot:m,publishedCanonicalSnapshot:k}=n.publishCompletedHostResult(o.intent,s.snapshot);return{kind:"completed",intent:o.intent,admission:c,publishedSnapshot:m,outcome:e.deriveExecutionOutcome(r,k),diagnostics:p}}function q(e){if(e.kind==="completed")return e.publishedSnapshot;throw e.kind==="rejected"?e.rejectionError:e.failure}function U(e){return e.kind==="completed"?Object.freeze({kind:"completed",intent:e.intent,admission:e.admission,outcome:e.outcome,diagnostics:e.diagnostics}):e.kind==="rejected"?Object.freeze({kind:"rejected",intent:e.intent,admission:e.admission,beforeSnapshot:e.beforeSnapshot,beforeCanonicalSnapshot:e.beforeCanonicalSnapshot,rejection:e.rejection}):Object.freeze({kind:"failed",intent:e.intent,admission:e.admission,beforeSnapshot:e.beforeSnapshot,beforeCanonicalSnapshot:e.beforeCanonicalSnapshot,error:e.errorInfo,published:e.published,...e.diagnostics!==void 0?{diagnostics:e.diagnostics}:{},...e.outcome!==void 0?{outcome:e.outcome}:{}})}function oe(e,t){if(t.kind==="unavailable")return e.createUnavailableError(t.intent);if(t.kind==="invalid-input")return t.error;if(t.kind==="not-dispatchable")return e.createNotDispatchableError(t.intent);throw new l("SDK_REPORT_ERROR","Cannot derive a rejected dispatch error for an admitted intent")}function ae(e){return e instanceof Error?e:new Error(String(e))}function W(e){let t=e[H],n=F({setVisibleSnapshot:e.setVisibleSnapshot,restoreVisibleSnapshot:e.restoreVisibleSnapshot,getCanonicalSnapshot:e.getCanonicalSnapshot,emitEvent:e.emitEvent});function a(c){if(e.isDisposed())return Promise.reject(new h);let s=e.ensureIntentId(c);return e.enqueue(async()=>{if(e.isDisposed())throw new h;return q(await M(e,t,n,s))})}function r(c){if(e.isDisposed())return Promise.reject(new h);let s=e.ensureIntentId(c);return e.enqueue(async()=>{if(e.isDisposed())throw new h;return U(await M(e,t,n,s))})}function i(c){return t.explainIntentFor(e.getCanonicalSnapshot(),c)}function o(c){return i(c)}function d(c){let s=i(c);return s.kind==="blocked"?s.blockers:null}return z({createIntent:e.createIntent,dispatchAsync:a,dispatchAsyncWithReport:r,subscribe:e.subscribe,on:e.on,getSnapshot:e.getSnapshot,getCanonicalSnapshot:e.getCanonicalSnapshot,getAvailableActions:e.getAvailableActions,isIntentDispatchable:e.isIntentDispatchable,getIntentBlockers:e.getIntentBlockers,explainIntent:i,why:o,whyNot:d,getActionMetadata:e.getActionMetadata,isActionAvailable:e.isActionAvailable,getSchemaGraph:e.getSchemaGraph,simulate:e.simulate,MEL:e.MEL,schema:e.schema,dispose:e.dispose},e)}import{createHostContextProvider as de,createHost as le,defaultRuntime as pe}from"@manifesto-ai/host";import{extractDefaults as me}from"@manifesto-ai/core";import{semanticPathToPatchPath as re}from"@manifesto-ai/core";function ie(e){return typeof e=="object"&&e!==null&&"key"in e&&"into"in e}function X(e,t){if(ie(e))return{patches:[{op:"set",path:J(e.into),value:se(e.key)}]};let{path:n,target:a}=e,r=ce(n,t);return a?{patches:[{op:"set",path:J(a),value:r.value}]}:{patches:[]}}function se(e){switch(e){case"uuid":return E();case"timestamp":case"time.now":return Date.now();case"isoTimestamp":return new Date().toISOString();default:return null}}function J(e){let t=Y(e),n=t.startsWith("data.")?t.slice(5):t;return re(n)}function Y(e){return e.startsWith("/")?e.slice(1).replace(/\//g,"."):e}function ce(e,t){let a=Y(e).split(".");if(a.length===0)return{value:void 0,found:!1};let[r,...i]=a,o;switch(r){case"data":o=t.data;break;case"computed":o=t.computed;break;case"system":o=t.system;break;case"meta":o=t.meta;break;default:o=t.data,i.unshift(r);break}for(let d of i){if(o==null||typeof o!="object")return{value:void 0,found:!1};o=o[d]}return{value:o,found:o!==void 0}}var S="system.get",P="system.",Q=Object.freeze({__baseLaws:!0});function D(e,t,n){let a=pe,r=le(e,{initialData:me(e.state),runtime:a}),i=de(a);r.registerEffect(S,async(o,d,c)=>{let{patches:s}=X(d,c.snapshot);return s});for(let[o,d]of Object.entries(n)){let c=async(s,p,m)=>await d(p,{snapshot:B(N(m.snapshot,t))});r.registerEffect(o,c)}return{host:r,contextProvider:i}}import{createIntent as ue}from"@manifesto-ai/core";function I(){return(e,...t)=>{let n=e,a=E(),r=fe(n,t);return ue(String(e.name),r,a)}}function fe(e,t){let n=Object.hasOwn(e,y)?e[y]:[];if(t.length!==0){if(n===null){if(t.length===1&&g(t[0]))return t[0];throw new l("INVALID_INTENT_ARGS",`Action "${String(e.name)}" requires a single object argument because positional parameter metadata is unavailable`)}if(n.length===0){if(t.length===1)return t[0];throw new l("INVALID_INTENT_ARGS",`Action "${String(e.name)}" does not accept multiple positional arguments`)}return n.length===1&&t.length===1&&g(t[0])&&e[b]?{[n[0]??"arg0"]:t[0]}:n.length===1&&t.length===1&&he(t[0],n[0])||t.length===1&&g(t[0])&&n.length>1?t[0]:Object.fromEntries(t.map((a,r)=>[n[r]??`arg${r}`,a]))}}function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function he(e,t){if(!t||!g(e))return!1;let n=Object.keys(e);return n.length===1&&n[0]===t}import{hashSchemaSync as Re}from"@manifesto-ai/core";import{compileMelDomain as ye,parse as Se,tokenize as be}from"@manifesto-ai/compiler";function Z(e){let t=ye(e,{mode:"domain"});if(t.errors.length>0){let a=t.errors.map(r=>{let i=r.location;if(!i||i.start.line===0&&i.start.column===0)return`[${r.code}] ${r.message}`;let o=`[${r.code}] ${r.message} (${i.start.line}:${i.start.column})`,d=e.split(`
|
|
2
|
+
`)[i.start.line-1];if(!d)return o;let c=String(i.start.line).padStart(4," "),s=Math.max(1,i.end.line===i.start.line?Math.min(i.end.column-i.start.column,Math.max(1,d.length-i.start.column+1)):1),p=" ".repeat(c.length+3+i.start.column-1);return`${o}
|
|
3
3
|
${c} | ${d}
|
|
4
|
-
${
|
|
4
|
+
${p}${"^".repeat(s)}`}).join(`
|
|
5
5
|
|
|
6
6
|
`);throw new j(t.errors,`MEL compilation failed:
|
|
7
|
-
${
|
|
7
|
+
${a}`)}if(!t.schema)throw new l("COMPILE_ERROR","MEL compilation produced no schema");let n=t.schema;return{schema:n,actionParamMetadata:C(n,Te(e)),actionSingleParamObjectValueMetadata:w(n)}}function C(e,t){return Object.freeze(Object.fromEntries(Object.entries(e.actions).map(([n,a])=>{let r=t?.[n];if(r&&r.length>0)return[n,Object.freeze([...r])];if(a.params&&a.params.length>0){let o=Object.freeze([...a.params]);return[n,o]}if(!a.input||a.input.type!=="object"||!a.input.fields)return[n,[]];let i=Ee(a.input);return[n,i.length<=1?i:null]})))}function w(e){return Object.freeze(Object.fromEntries(Object.entries(e.actions).map(([t,n])=>[t,ge(e,n)])))}function Ee(e){return!e||e.type!=="object"||!e.fields?[]:Object.keys(e.fields)}function ge(e,t){if(t.params?.length===1&&t.inputType){let n=x(t.inputType,t.params[0]??"",e.types);return n?O(n,e.types):!1}if(t.input?.type==="object"&&t.input.fields&&Object.keys(t.input.fields).length===1){let[n]=Object.keys(t.input.fields);return(n?t.input.fields[n]:void 0)?.type==="object"}return!1}function x(e,t,n,a=[]){if(e.kind==="ref"){if(a.includes(e.name))return null;let r=n[e.name];return r?x(r.definition,t,n,[...a,e.name]):null}if(e.kind==="union"){let r=e.types.filter(i=>!v(i,n,a));return r.length===1?x(r[0],t,n,a):null}return e.kind!=="object"?null:e.fields[t]?.type??null}function O(e,t,n=[]){if(e.kind==="ref"){if(n.includes(e.name))return!1;let a=t[e.name];return a?O(a.definition,t,[...n,e.name]):!1}if(e.kind==="union"){let a=e.types.filter(r=>!v(r,t,n));return a.length===1?O(a[0],t,n):!1}return e.kind==="object"||e.kind==="record"||e.kind==="primitive"&&e.type==="object"}function v(e,t,n=[]){if(e.kind==="ref"){if(n.includes(e.name))return!1;let a=t[e.name];return a?v(a.definition,t,[...n,e.name]):!1}return e.kind==="primitive"&&e.type==="null"||e.kind==="literal"&&e.value===null}function Te(e){let t=be(e);if(t.diagnostics.some(a=>a.severity==="error"))return;let n=Se(t.tokens);if(n.program)return Object.freeze(Object.fromEntries(n.program.domain.members.filter(a=>a.kind==="action").map(a=>[a.name,Object.freeze(a.params.map(r=>r.name))])))}function ee(e){if(typeof e!="string"&&je(e))throw new l("SCHEMA_ERROR","DomainModule is a compiler tooling artifact. Pass module.schema or MEL source to createManifesto().");let t=typeof e=="string"?Z(e):{schema:e,actionParamMetadata:C(e),actionSingleParamObjectValueMetadata:w(e)},n=Ae(t.schema);return Me(n),{schema:n,actionParamMetadata:t.actionParamMetadata,actionSingleParamObjectValueMetadata:t.actionSingleParamObjectValueMetadata,projectionPlan:L(n)}}function je(e){return typeof e=="object"&&e!==null&&Object.hasOwn(e,"schema")&&Object.hasOwn(e,"graph")&&Object.hasOwn(e,"annotations")}function Ae(e){let t={...e.state.fields},n=!1;if(!t.$host)t.$host={type:"object",required:!1,default:{}},n=!0;else{if(t.$host.type!=="object")throw new l("SCHEMA_ERROR","Reserved namespace '$host' must be an object field");t.$host.default===void 0&&(t.$host={...t.$host,default:{}},n=!0)}if(!t.$mel)t.$mel={type:"object",required:!1,default:{guards:{intent:{}}},fields:{guards:{type:"object",required:!1,default:{intent:{}},fields:{intent:{type:"object",required:!1,default:{}}}}}},n=!0;else{if(t.$mel.type!=="object")throw new l("SCHEMA_ERROR","Reserved namespace '$mel' must be an object field");{let o=t.$mel;o.default===void 0&&(o={...o,default:{guards:{intent:{}}}},n=!0);let d=o.fields??{},c=d.guards;if(!c)o={...o,fields:{...d,guards:{type:"object",required:!1,default:{intent:{}},fields:{intent:{type:"object",required:!1,default:{}}}}}},n=!0;else{if(c.type!=="object")throw new l("SCHEMA_ERROR","Reserved namespace '$mel.guards' must be an object field");{let s=c;s.default===void 0&&(s={...s,default:{intent:{}}},n=!0);let p=s.fields??{},m=p.intent;if(!m)s={...s,fields:{...p,intent:{type:"object",required:!1,default:{}}}},n=!0;else{if(m.type!=="object")throw new l("SCHEMA_ERROR","Reserved namespace '$mel.guards.intent' must be an object field");m.default===void 0&&(s={...s,fields:{...p,intent:{...m,default:{}}}},n=!0)}s!==c&&(o={...o,fields:{...d,guards:s}})}}o!==t.$mel&&(t.$mel=o)}}if(!n)return e;let a={...e,state:{...e.state,fields:t}},{hash:r,...i}=a;return{...a,hash:Re(i)}}function Me(e){for(let t of Object.keys(e.actions??{}))if(t.startsWith(P))throw new l("RESERVED_NAMESPACE",`Action type "${t}" uses reserved namespace prefix "${P}"`)}function _(e,t,n){let a=Object.fromEntries(Object.keys(e.actions).map(o=>{let d={__kind:"ActionRef",name:o};return Object.defineProperty(d,y,{enumerable:!1,configurable:!1,writable:!1,value:Object.hasOwn(t,o)?t[o]:[]}),Object.defineProperty(d,b,{enumerable:!1,configurable:!1,writable:!1,value:n[o]??!1}),[o,Object.freeze(d)]})),r=Object.fromEntries(Object.keys(e.state.fields).filter(o=>!o.startsWith("$")).map(o=>[o,Object.freeze({__kind:"FieldRef",name:o})])),i=Object.fromEntries(Object.keys(e.computed.fields).map(o=>[o,Object.freeze({__kind:"ComputedRef",name:o})]));return Object.freeze({actions:Object.freeze(a),state:Object.freeze(r),computed:Object.freeze(i)})}function te(e,t){if(S in t)throw new R(S);let n=ee(e),a={_laws:Q,schema:n.schema,activate(){K(a);let r=D(n.schema,n.projectionPlan,t);return W(A({schema:n.schema,projectionPlan:n.projectionPlan,host:r.host,hostContextProvider:r.contextProvider,MEL:_(n.schema,n.actionParamMetadata,n.actionSingleParamObjectValueMetadata),createIntent:I()}))}};return G(a,()=>{let r=D(n.schema,n.projectionPlan,t);return A({schema:n.schema,projectionPlan:n.projectionPlan,host:r.host,hostContextProvider:r.contextProvider,MEL:_(n.schema,n.actionParamMetadata,n.actionSingleParamObjectValueMetadata),createIntent:I()})})}import{createSnapshot as Tt}from"@manifesto-ai/core";export{ne as AlreadyActivatedError,j as CompileError,h as DisposedError,l as ManifestoError,R as ReservedEffectError,te as createManifesto,Tt as createSnapshot};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifesto-ai/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
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,14 +47,14 @@
|
|
|
47
47
|
"dist"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
+
"@manifesto-ai/core": "2.12.0",
|
|
50
51
|
"@manifesto-ai/host": "2.9.0",
|
|
51
|
-
"@manifesto-ai/compiler": "3.
|
|
52
|
-
"@manifesto-ai/core": "2.12.0"
|
|
52
|
+
"@manifesto-ai/compiler": "3.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"typescript": "^5.9.3",
|
|
56
|
-
"vite": "^8.0.
|
|
57
|
-
"vitest": "^4.1.
|
|
56
|
+
"vite": "^8.0.8",
|
|
57
|
+
"vitest": "^4.1.4"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "rm -rf dist && tsup && tsc -p tsconfig.build.json --emitDeclarationOnly --declarationMap false --outDir dist",
|