@decentrys/agent 0.1.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/LICENSE +21 -0
- package/README.md +62 -0
- package/dist/browser/decentrys-agent.js +2051 -0
- package/dist/browser/decentrys-agent.mjs +2026 -0
- package/dist/client.d.ts +194 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +303 -0
- package/dist/client.js.map +1 -0
- package/dist/explain.d.ts +63 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +144 -0
- package/dist/explain.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +166 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +218 -0
- package/dist/ledger.js.map +1 -0
- package/dist/model.d.ts +256 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +74 -0
- package/dist/model.js.map +1 -0
- package/dist/policy.d.ts +137 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +845 -0
- package/dist/policy.js.map +1 -0
- package/package.json +64 -0
- package/src/client.test.ts +351 -0
- package/src/client.ts +392 -0
- package/src/explain.test.ts +148 -0
- package/src/explain.ts +204 -0
- package/src/index.ts +5 -0
- package/src/ledger.test.ts +192 -0
- package/src/ledger.ts +303 -0
- package/src/model.ts +324 -0
- package/src/policy.test.ts +762 -0
- package/src/policy.ts +951 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Decentrys Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @decentrys/agent
|
|
2
|
+
|
|
3
|
+
AgentGuard: policy enforcement in front of an autonomous on-chain agent.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @decentrys/agent @decentrys/protect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Why this is not @decentrys/protect
|
|
12
|
+
|
|
13
|
+
Protect informs a human, who then decides. An agent has no judgement and will
|
|
14
|
+
do exactly what it is told, at machine speed, repeatedly. A person seeing
|
|
15
|
+
"unlimited approval requested" may reconsider; an agent will not.
|
|
16
|
+
|
|
17
|
+
So where Protect warns and never blocks, AgentGuard exists to be able to
|
|
18
|
+
**stop** an action — under a policy its operator set in advance.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const policy = sealPolicy({
|
|
22
|
+
maxValuePerActionUsd: 5_000,
|
|
23
|
+
cumulative: [{ windowMs: 86_400_000, maxUsd: 25_000 }],
|
|
24
|
+
allowedActions: ['swap'], // may swap, may not approve
|
|
25
|
+
allowUnlimitedApproval: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const guard = new AgentGuard({ apiKey: 'dk_live_...', policy });
|
|
29
|
+
const decision = await guard.assessAgentTransaction(action);
|
|
30
|
+
|
|
31
|
+
decision.verdict // 'allow' | 'require_human_approval' | 'deny'
|
|
32
|
+
decision.evaluations // every rule considered, passes included
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## The agent cannot widen its own limits
|
|
36
|
+
|
|
37
|
+
A sealed policy is branded with a runtime symbol and deep-frozen, with your
|
|
38
|
+
arrays cloned away. There is **no widening function in this package** —
|
|
39
|
+
`narrowPolicy` only ever tightens.
|
|
40
|
+
|
|
41
|
+
## `failMode` defaults to `escalate`
|
|
42
|
+
|
|
43
|
+
`open` signs unscreened during exactly the window an attacker would choose.
|
|
44
|
+
`closed` halts the agent entirely, which for a liquidation agent is its own
|
|
45
|
+
loss and pressures operators into choosing `open`. `escalate` spends a human's
|
|
46
|
+
attention instead of the treasury. An outage removes one input but never
|
|
47
|
+
suspends your limits.
|
|
48
|
+
|
|
49
|
+
## Known limit, stated plainly
|
|
50
|
+
|
|
51
|
+
The bundled spend ledger is **in-process**. Two replicas each enforcing
|
|
52
|
+
$10,000/day enforce $20,000, and a restart resets the window. Swap in shared
|
|
53
|
+
storage via the two-method `AgentUsage` interface before running a fleet.
|
|
54
|
+
|
|
55
|
+
## Licence
|
|
56
|
+
|
|
57
|
+
MIT © Decentrys Labs
|
|
58
|
+
|
|
59
|
+
## Links
|
|
60
|
+
|
|
61
|
+
- [decentrys.com](https://decentrys.com) · [SDK overview](https://decentrys.com/sdk) · [Developer API](https://decentrys.com/developers)
|
|
62
|
+
- Source: [github.com/teamdecentrys-byte/Decentrys](https://github.com/teamdecentrys-byte/Decentrys)
|