SolidLabResearch / Solid-Agent

A rule-based intelligent software agent
8 stars 1 forks source link

Add documentation to execute the simple sync demo #3

Open woutslabbinck opened 1 year ago

woutslabbinck commented 1 year ago

Start with the following

Install project

npm i https://github.com/woutslabbinck/Solid-Agent --save-dev

Solid Sync Demo

# set up a Solid server
npx @solid/community-server -c @css:config/file-no-setup.json -f ./data
# create a state resource
curl -X PUT -d "". http://localhost:3000/state -H "content-type: text/turtle"

execute following code

const {DemoSyncAgent, SubscriptionEnum} = require("solid-agent")

async function main(){
    const demo = new DemoSyncAgent({
        solid: {
            solidResources: ['http://localhost:3000/state'],
            subscriptionType: {type: SubscriptionEnum.PUSH}
        }
    })
    await demo.start()
}

Execute a curl request to change the state resource

curl -X PUT -d "<a> <b> <c>". http://localhost:3000/state -H "content-type: text/turtle"

You will see that two resources wil be created http://localhost:3000/random and http://localhost:3000/test, which both contain the exact same content as http://localhost:3000/state which you just updated.

That is due the simple demo agent executing following rules, which will execute the fnoUpdateSolidState plugin.

j-steinbach commented 1 year ago

The code execution is missing a main() afterwards, to call the function.