Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "aagent.js", | ||
"version": "0.0.6", | ||
"description": "It is CLI to work with Autonomous Agents on Obyte", | ||
"version": "0.0.7", | ||
"description": "It is library to work with Autonomous Agents on Obyte", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"bin": { | ||
"aagent": "./cli.js" | ||
"dependencies": { | ||
"headless-obyte": "https://github.com/byteball/headless-obyte" | ||
}, | ||
"keywords": [ | ||
"obyte", | ||
"framework", | ||
"library", | ||
"aa", | ||
@@ -27,12 +28,3 @@ "autonomous", | ||
"url": "https://github.com/olabs-org/aagent.js/issues" | ||
}, | ||
"dependencies": { | ||
"fs-extra": "^9.0.0", | ||
"global": "^4.4.0", | ||
"ocore": "git+https://github.com/byteball/ocore.git", | ||
"open": "^7.0.4", | ||
"request": "^2.88.2", | ||
"request-promise": "^4.2.5", | ||
"yargs": "^15.3.1" | ||
} | ||
} |
193
README.md
@@ -1,40 +0,191 @@ | ||
# aagent.js | ||
### What's it? | ||
It is CLI and [library](https://github.com/olabs-org/aagent.js-lib) to work with Autonomous Agents on Obyte | ||
It is [CLI](https://github.com/olabs-org/aagent-cli) and library to work with Autonomous Agents on Obyte | ||
## CLI | ||
Init | ||
### Quick start | ||
You can create a new project using [CLI](https://github.com/olabs-org/aagent-cli) | ||
```bash | ||
npm i -g aagent.js | ||
aagent --help | ||
npm i -g aagent-cli | ||
aagent init folder | ||
``` | ||
Create project from [template](template) (with AA example, tests and library) | ||
Or add to an existing project | ||
```bash | ||
aagent init folder | ||
yarn add aagent.js | ||
``` | ||
```javascript | ||
require('headless-obyte'); | ||
const eventBus = require('ocore/event_bus'); | ||
const { AA, AAs } = require('aagent.js'); | ||
``` | ||
## Library | ||
### AA | ||
Example: | ||
```javascript | ||
require('headless-obyte'); | ||
const eventBus = require('ocore/event_bus'); | ||
const { AA } = require('aagent.js'); | ||
eventBus.on('headless_wallet_ready', () => { | ||
const aa = new AA('address'); | ||
aa.events.on('new_request', (request) => { | ||
console.error('new request', request); | ||
}); | ||
aa.events.on('new_response', (err, response, vars) => { | ||
console.error('new response', response, vars); | ||
}); | ||
aa.events.on('new_aa_definition', (definition) => { | ||
console.error('new aa definition', definition); | ||
}); | ||
aa.events.on('new_aa_definition_saved', (definition) => { | ||
console.error('new aa definition saved', definition); | ||
}); | ||
aa.newResponseFilter((err, params, vars) => { | ||
return true; | ||
}, (err, params, vars) => { | ||
console.error(err, params, vars); | ||
}); | ||
}); | ||
``` | ||
<br> | ||
Validating AA | ||
```bash | ||
aagent validate aa.oscript | ||
#### AA class contains the following methods: | ||
All events are applied to the specified address in the constructor. | ||
##### constructor | ||
```javascript | ||
const aa = new AA('address') | ||
``` | ||
one argument - aa_address(string) | ||
static method **getAAVars**: | ||
```javascript | ||
AA.getAAVars('address'); | ||
``` | ||
will return variables from AA. | ||
<br> | ||
Open GUI Wallet to deploy | ||
```bash | ||
aagent deploy aa.oscript | ||
#### Event handlers: | ||
The handler triggers an event, passes it to the first function, and if it returns true, calls the second function. You can use them to process specific data(like a router). | ||
<br>**More about arguments in events.** | ||
<br> | ||
```javascript | ||
aa.addRequestEventHandler((request, body) => { | ||
return true; | ||
}, (request, body) => { | ||
console.error(request, body); | ||
}); | ||
``` | ||
*If the file is too large it will be uploaded to the server and transferred to the client in the link.* <br> | ||
This command supports argument **--testnet** to deploy script through the testnet or mainnet wallet. | ||
```javascript | ||
aa.addResponseEventHandler((err, params, vars, body) => { | ||
return true; | ||
}, (err, params, vars, body) => { | ||
console.error(err, params, vars, body); | ||
}); | ||
``` | ||
```javascript | ||
aa.addDefinitionEventHandler((definition, body) => { | ||
return true; | ||
}, (definition, body) => { | ||
console.error(definition, body); | ||
}); | ||
``` | ||
```javascript | ||
aa.addDefinitionSavedEventHandler((definition, body) => { | ||
return true; | ||
}, (definition, body) => { | ||
console.error(definition, body); | ||
}); | ||
``` | ||
<br> | ||
#### And events: | ||
##### new_request | ||
```javascript | ||
aa.events.on('new_request', (request, body) => { | ||
console.error('new request', request, body); | ||
}); | ||
``` | ||
Arguments: | ||
- request - {address: aa_address, messages: unit.messages} | ||
- body - raw body from event | ||
<br> | ||
Start tests | ||
```bash | ||
yarn test | ||
##### new_response | ||
```javascript | ||
aa.events.on('new_response', (err, params, vars, body) => { | ||
console.error('new response', err, params, vars, body); | ||
}); | ||
``` | ||
Arguments: | ||
- err - if *bounced* return error message | ||
- params - { address: aa_address, response: body.response } | ||
- vars - new vars from AA | ||
- body - raw body from event | ||
<br> | ||
#### If you want to start developing on Obyte and you need help, write to us on [discord](https://obyte.org/discord) or on telegram: @xJeneK | ||
##### new_aa_definition | ||
```javascript | ||
aa.events.on('new_aa_definition', (definition, body) => { | ||
console.error('new aa definition', definition, body); | ||
}); | ||
``` | ||
Arguments: | ||
- definition - definition from messages | ||
- body - raw body from event | ||
<br> | ||
##### new_aa_definition_saved | ||
```javascript | ||
aa.events.on('new_aa_definition_saved', (definition, body) => { | ||
console.error('new aa definition saved', definition, body); | ||
}); | ||
``` | ||
*This event can be triggered twice with the same data (architectural features), please consider this.*<br> | ||
Arguments: | ||
- definition - definition from messages | ||
- body - raw body from event | ||
--- | ||
### AAs | ||
All events applies to the specified addresses in the constructor. | ||
##### constructor | ||
```javascript | ||
const aas = new AAs(['address', 'address2']) | ||
``` | ||
one argument - aa_addresses - array[string] | ||
<br> | ||
```javascript | ||
aas.addAddress('address'); | ||
``` | ||
Adds a new address and subscribes to it | ||
<br> | ||
static method **getAAVars**: | ||
```javascript | ||
AAs.getAAVars('address'); | ||
``` | ||
will return variables from AA. | ||
This class supports only: <br> | ||
**Methods**: addRequestEventHandler, addResponseEventHandler <br> | ||
**Events**: new_request, new_response<br><br> | ||
**Arguments are identical to AA class** | ||
<br> | ||
#### If you want to start developing on Obyte and you need help, write to us on [discord](https://obyte.org/discord) or on telegram: @xJeneK |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
10878
1
191
0
5
154
2
+ Addedheadless-obyte@https://github.com/byteball/headless-obyte
- Removedfs-extra@^9.0.0
- Removedglobal@^4.4.0
- Removedopen@^7.0.4
- Removedrequest@^2.88.2
- Removedrequest-promise@^4.2.5
- Removedyargs@^15.3.1
- Removedajv@6.12.6(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedat-least-node@1.0.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcliui@6.0.0(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedfs-extra@9.1.0(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglobal@4.4.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-docker@2.2.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedis-wsl@2.2.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonfile@6.1.0(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmin-document@2.19.0(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedopen@7.4.2(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduniversalify@2.0.1(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@15.4.1(transitive)
- Removedyargs-parser@18.1.3(transitive)