npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koreografeye

v0.5.0

Published

A Solid choreography / orchestrator agent with a reasoning component

Downloads

97

Readme

Koreografeye

npm

Koreografeye is a choreography / orchestration engine for linked data services using Notation3 (N3) rule engines such as EYE.

Koreografeye was created to facilitate automated processes against Solid pods. Our main use case is monitoring the LDN Inbox of Solid Pods for new notifications and running scripts when new data arrives.

Usage

Configuration

Create a project directory.

mkdir demo
cd demo

Add the koreografeye dependency (and solid-bashlib in case you want to monitor private Solid resources).

npm install koreografeye
npm install solid-bashlib

Create input, output and rules directories.

mkdir input output rules

Prepare some input data

Put a demo.jsonld AS2 notification in the input directory.

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://purl.org/coar/notify"
  ],
  "id": "urn:uuid:0370c0fb-bb78-4a9b-87f5-bed307a509dd",
  "type": "Offer",
  "actor": {
    "id": "https://mypod.org/profile/card#me",
    "name": "Freddy Test",
    "type": "Person"
  },
  "object": "https://research-organisation.org/repository/preprint/201203/421/"
}

Create a demo.n3 N3 rule file in the rules directory.

@prefix ex:   <http://example.org/> .
@prefix as:   <https://www.w3.org/ns/activitystreams#> .
@prefix pol:  <https://www.example.org/ns/policy#> .
@prefix fno:  <https://w3id.org/function/ontology#> .

{
    # if we get an offer 
    ?id a as:Offer .
    ?id as:actor ?actor .
}
=>
{
    # Send an accept notification to an LDN inbox
    ex:MySendNotificationDemo pol:policy ex:MySendNotificationDemoExecution.
    ex:MySendNotificationDemoExecution 
        a fno:Execution ;
        fno:executes ex:sendNotification ;
        ex:to <http://httpbin.org/post> ;
        ex:notification ex:MyNotification .
    
    ex:MyNotification 
        a as:Accept ;
        as:inReplyTo ?id ;
        as:actor     <http://my.service.edu/profile/card#me> ;
        as:object    ?id .
}.

Run orch

The orch command will take the input data and use the N3 rules to decide what to do with the data. No actions are taken yet. These will be done by the pol command.

npx orch --info --keep --in input --out output rules/demo.n3

The processed notifications will end up in the output directory

Run pol

The pol command will take the output of the orch command and execute the requested policies defined with the N3 rules.

npx pol --info --keep --in output

The result will be an AS2 that is send to the http://httpbin.org/post address.

Experiment

Using Koreografeye plugins you can experiment with:

  • Sending emails
  • Sending notifications
  • Sending push messages to your phone
  • Updating Solid Pods
  • Sending toot messages to a Mastodon account

Check the Git repository https://github.com/eyereasoner/Koreografeye for more examples.

We use the Bashlib to monitor remote Solid LDN inboxes for new notification.

E.g. move the contents of your inbox to the input directory.

npx sld mv https://yourpod.org/inbox/ input/

This assumes you have an authenticated Bashlib session. Use the bashlib auth create-token command to create a token for the CSS Solid pod.

Typescript/javascript

One can also use JavaScript to execute the orch and pol commands:

const { 
    parseAsN3Store, 
    readText, 
    topGraphIds, 
    storeAddPredicate, 
    makeComponentsManager,
    executePolicies
} = require('koreografeye');

main();

async function main() {
    const inputData  = './input/demo.jsonld';
    const inputRules = './rules/demo.n3';

    // Read the input graph as an N3 store
    const store  = await parseAsN3Store(inputData); 
    // Read the N3 rules as an array of strings
    const rules  = [readText(inputRules)]; 

    // Load the components we need for reasoning
    const manager = await makeComponentsManager(undefined,'.');

    // Get a reasoner
    const reasoner = await manager.instantiate('urn:koreografeye:reasonerInstance');

    // Execute the reasoner (orch)
    const resultStore = await reasoner.reason(store, rules);

    // Execute the policies (pol)
    const numOfErrors = await executePolicies(manager, resultStore);

    console.log(`found ${numOfErrors} errors`);
}

Run this code with:

node demo.js

Commands

orch

Run the orchstrator with one or more N3 rule files on an input directory of notifications.

bin/orch [options] rule [rule ...]

Options:

  • --config file : orchestrator configuration file
  • --in directory : directory with input notifications
  • --out directory : directory with orchestrator output
  • --err directory : directory with failed notifications
  • --single file : process only a single file
  • --keep : keep the --in data (don't delete after processing)
  • --info : verbose messages
  • --debug : debug messages
  • --trace : trace messages

pol

Run a policy executor on one of the output files of the orchestrator

bin/pol [options]

Options:

  • --config file : orchestrator configuration file
  • --in directory : directory with input notifications
  • --out directory : directory with orchestrator output
  • --err directory : directory with failed notifications
  • --single file : process only a single file
  • --keep : keep the --in data (don't delete after processing)
  • --info : verbose messages
  • --debug : debug messages
  • --trace : trace messages

Examples implementations