@decentrys/agent 0.1.1 → 0.1.2
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 +158 -43
- package/dist/browser/decentrys-agent.js +2 -2
- package/dist/browser/decentrys-agent.mjs +2 -2
- package/dist/client.d.ts +8 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -1
- package/dist/client.js.map +1 -1
- package/dist/model.d.ts +3 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +8 -1
- package/src/model.ts +3 -2
package/README.md
CHANGED
|
@@ -14,93 +14,154 @@ So where Protect warns and never blocks, AgentGuard exists to be able to
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @decentrys/agent
|
|
17
|
+
npm install @decentrys/agent
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
`@decentrys/protect` is a dependency and is installed with it; the risk model
|
|
21
|
+
is not reimplemented here. Node 18+. Types included.
|
|
22
|
+
|
|
20
23
|
## Getting an API key
|
|
21
24
|
|
|
22
25
|
Sign in at [decentrys.com/developers](https://decentrys.com/developers) and create a key.
|
|
23
26
|
|
|
24
|
-
There are two kinds, and picking the wrong one is the mistake that matters:
|
|
25
|
-
|
|
26
27
|
| Prefix | Where it belongs | Why |
|
|
27
28
|
|---|---|---|
|
|
28
29
|
| `dk_pub_live_…` | **Publishable.** Ships inside a wallet, extension or mobile app. | Bounded to the origins you register and to read-only Protect endpoints. Anyone can extract it from your bundle; that's expected, and it's why it can't do anything dangerous. |
|
|
29
30
|
| `dk_live_…` | **Secret.** Server-side only. | Full scope access. If this ends up in a client bundle it is a leaked credential the moment it ships. |
|
|
30
31
|
|
|
31
|
-
**Secret key only.**
|
|
32
|
+
**Secret key only.** An agent runtime is server-side.
|
|
32
33
|
|
|
33
|
-
##
|
|
34
|
+
## 1. The operator writes a policy, ahead of time
|
|
34
35
|
|
|
35
36
|
```ts
|
|
36
37
|
import { AgentGuard, sealPolicy } from '@decentrys/agent';
|
|
37
38
|
|
|
38
|
-
// The operator sets this, ahead of time. The agent never sees a mutable copy.
|
|
39
39
|
const policy = sealPolicy({
|
|
40
|
+
version: 'treasury-rebalancer-3', // recorded on every decision
|
|
41
|
+
agentId: 'rebalancer-1', // this policy is not another agent's
|
|
42
|
+
|
|
40
43
|
maxValuePerActionUsd: 5_000,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
spendWindows: [{ label: 'daily', windowMs: 86_400_000, maxValueUsd: 25_000 }],
|
|
45
|
+
rateWindows: [{ label: 'per-minute', windowMs: 60_000, maxActions: 10 }],
|
|
46
|
+
|
|
47
|
+
allowedActions: ['swap', 'transfer'], // may swap, may NOT approve
|
|
44
48
|
allowedChains: ['ethereum', 'base'],
|
|
45
|
-
blockedCounterparties: ['0xbad
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
blockedCounterparties: ['0xbad…'],
|
|
50
|
+
allowUnlimitedApprovals: false, // this is already the default
|
|
51
|
+
|
|
52
|
+
maxRiskLevel: 'CAUTION', // deny anything strictly above
|
|
53
|
+
humanApprovalAboveUsd: 10_000,
|
|
49
54
|
failMode: 'escalate',
|
|
50
55
|
});
|
|
51
56
|
|
|
52
|
-
const guard = new AgentGuard({ apiKey:
|
|
57
|
+
const guard = new AgentGuard({ apiKey: process.env.DECENTRYS_API_KEY!, policy });
|
|
58
|
+
|
|
59
|
+
for (const warning of guard.policyWarnings) console.warn(warning);
|
|
53
60
|
```
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
Every field is optional, and an omitted field means *unconstrained on that
|
|
63
|
+
axis* — with one exception: `allowUnlimitedApprovals` defaults to refusing,
|
|
64
|
+
because an unlimited approval is the one action that turns a bounded mistake
|
|
65
|
+
into an unbounded one.
|
|
66
|
+
|
|
67
|
+
`sealPolicy` deep-freezes the object, clones your arrays away from you, and
|
|
68
|
+
brands the result with a module-private symbol. `AgentGuard` accepts nothing
|
|
69
|
+
else, so a policy the agent constructed does not typecheck and would not
|
|
70
|
+
survive sealing if it did.
|
|
71
|
+
|
|
72
|
+
Full field list: `version` · `agentId` · `risk` · `maxRiskLevel` ·
|
|
73
|
+
`maxValuePerActionUsd` · `spendWindows` · `rateWindows` ·
|
|
74
|
+
`allowedCounterparties` · `blockedCounterparties` · `allowedContracts` ·
|
|
75
|
+
`allowedTokens` · `allowedActions` · `deniedActions` · `allowedChains` ·
|
|
76
|
+
`allowUnlimitedApprovals` · `humanApprovalAboveUsd` ·
|
|
77
|
+
`humanApprovalAtRiskLevel` · `failMode`.
|
|
78
|
+
|
|
79
|
+
Action types: `transfer` · `swap` · `approve` · `contract_call` · `bridge` ·
|
|
80
|
+
`stake` · `unstake` · `deploy` · `sign_message` · `unknown`.
|
|
81
|
+
|
|
82
|
+
## 2. The agent's execution loop asks before it signs
|
|
56
83
|
|
|
57
84
|
```ts
|
|
58
85
|
const decision = await guard.assessAgentTransaction({
|
|
86
|
+
agentId: 'rebalancer-1', // required — limits are held per agent, not per process
|
|
59
87
|
chain: 'ethereum',
|
|
88
|
+
type: 'swap', // an AgentActionType, not a free string
|
|
60
89
|
from: agentWallet,
|
|
61
90
|
to: routerAddress,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
idempotencyKey: taskId,
|
|
91
|
+
valueUsd: 2_500, // as YOU price it; AgentGuard never prices anything
|
|
92
|
+
idempotencyKey: taskId, // a retry is one action, not two
|
|
65
93
|
});
|
|
66
94
|
|
|
67
95
|
switch (decision.verdict) {
|
|
68
|
-
case 'allow':
|
|
69
|
-
try {
|
|
70
|
-
|
|
96
|
+
case 'allow': {
|
|
97
|
+
try {
|
|
98
|
+
const txHash = await signAndSend();
|
|
99
|
+
guard.confirm(decision.decisionId, { txHash }); // the hold becomes a commitment
|
|
100
|
+
} catch {
|
|
101
|
+
guard.release(decision.decisionId, { note: 'broadcast failed' }); // hand the budget back
|
|
102
|
+
}
|
|
71
103
|
break;
|
|
104
|
+
}
|
|
72
105
|
|
|
73
106
|
case 'require_human_approval':
|
|
74
107
|
await notifyOperator(guard.explain(decision));
|
|
75
108
|
break;
|
|
76
109
|
|
|
77
110
|
case 'deny':
|
|
78
|
-
|
|
111
|
+
console.error(guard.explain(decision)?.text);
|
|
79
112
|
break;
|
|
80
113
|
}
|
|
81
114
|
```
|
|
82
115
|
|
|
116
|
+
`confirm` and `release` take the **`decisionId`**, not the decision object, and
|
|
117
|
+
are synchronous — they return an `AgentOutcomeRecord | null`, `null` when this
|
|
118
|
+
guard holds no reservation for that id.
|
|
119
|
+
|
|
83
120
|
Three verdicts, not two. Protect's `warn` has no recipient here — there's no
|
|
84
|
-
human watching — so
|
|
85
|
-
|
|
121
|
+
human watching — so `sealPolicy` **throws** if a `risk` map contains `warn` or
|
|
122
|
+
`warn_strong`, rather than silently reinterpreting it.
|
|
86
123
|
|
|
87
|
-
## The agent cannot widen its own limits
|
|
124
|
+
## 3. The agent cannot widen its own limits
|
|
88
125
|
|
|
89
|
-
A sealed policy is branded with a runtime symbol, deep-frozen, and your arrays
|
|
90
|
-
are cloned away — an operator holding a reference can't grow a live allowlist.
|
|
91
126
|
**There is no widening function in this package.** `narrowPolicy` only ever
|
|
92
|
-
tightens:
|
|
127
|
+
tightens: minimum of caps, intersection of allowlists, union of blocklists,
|
|
128
|
+
windows accumulated, `allowUnlimitedApprovals` true only if both sides say so,
|
|
129
|
+
and the stricter `failMode`.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
// A guard for a narrower sub-task, sharing this one's ledger and Protect client.
|
|
133
|
+
const subTask = guard.withPolicy({ maxValuePerActionUsd: 500, allowedActions: ['swap'] });
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`withPolicy` takes a plain `AgentPolicy` restriction and narrows internally —
|
|
137
|
+
don't pre-apply `narrowPolicy` yourself. The shared ledger is the point: a
|
|
138
|
+
sub-task spending against a tighter per-task cap still spends against the
|
|
139
|
+
agent's daily one.
|
|
140
|
+
|
|
141
|
+
A per-call restriction works the same way and is equally one-directional:
|
|
93
142
|
|
|
94
143
|
```ts
|
|
95
|
-
|
|
144
|
+
await guard.assessAgentTransaction(action, { restrict: { maxValuePerActionUsd: 100 } });
|
|
96
145
|
```
|
|
97
146
|
|
|
98
|
-
## Every allow is explainable afterwards
|
|
147
|
+
## 4. Every allow is explainable afterwards
|
|
99
148
|
|
|
100
149
|
```ts
|
|
101
|
-
decision.evaluations
|
|
102
|
-
|
|
103
|
-
|
|
150
|
+
decision.evaluations // EVERY rule considered, passes included
|
|
151
|
+
decision.reasons // the failing and escalating ones
|
|
152
|
+
decision.policyFingerprint // which rules were in force
|
|
153
|
+
decision.actionDigest // ties the record to what was proposed
|
|
154
|
+
decision.assessment // the Protect assessment used, when one was obtained
|
|
155
|
+
|
|
156
|
+
const explanation = guard.explain(decision); // AgentActionExplanation | null
|
|
157
|
+
explanation?.headline; // one sentence: what happened, and at the top level why
|
|
158
|
+
explanation?.because; // the rules that blocked or escalated, in their own words
|
|
159
|
+
explanation?.rulesApplied; // all of them
|
|
160
|
+
explanation?.unbounded; // axes this policy set no bound on at all
|
|
161
|
+
explanation?.toProceed; // what the OPERATOR would have to change
|
|
162
|
+
explanation?.text; // plain-text rendering, for a log line or a review queue
|
|
163
|
+
|
|
164
|
+
guard.auditLog({ verdict: 'deny' }); // in memory, bounded, dies with the process
|
|
104
165
|
```
|
|
105
166
|
|
|
106
167
|
Evaluation never short-circuits, so a record can't say "exceeded its cap" while
|
|
@@ -109,8 +170,18 @@ distinguished from `not_applicable`, so you can see which axes your policy left
|
|
|
109
170
|
**unbounded** — the difference between "the rate ceiling was checked" and "there
|
|
110
171
|
is no rate ceiling".
|
|
111
172
|
|
|
112
|
-
|
|
113
|
-
|
|
173
|
+
`auditLog()` is a convenience, not an audit trail. For one that survives a
|
|
174
|
+
restart, pass `onDecision` — invoked synchronously for every decision, with its
|
|
175
|
+
exceptions swallowed so a logging sink can never change a verdict:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
new AgentGuard({ apiKey, policy, onDecision: (d) => writeAuditRow(d) });
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`evaluatePolicy` is pure and clock-injected, and a decision carries its policy
|
|
182
|
+
fingerprint and action digest, so a recorded decision replays to the same
|
|
183
|
+
answer. `guard.evaluate(action, { assessment })` runs the same rules with no
|
|
184
|
+
network call.
|
|
114
185
|
|
|
115
186
|
## failMode defaults to `escalate`
|
|
116
187
|
|
|
@@ -122,20 +193,64 @@ attention instead of the treasury.
|
|
|
122
193
|
An outage removes one input but **never suspends your limits**: a local `deny`
|
|
123
194
|
still denies under `failMode: 'open'`.
|
|
124
195
|
|
|
125
|
-
|
|
196
|
+
The default risk mapping for an agent (`DEFAULT_AGENT_RISK_POLICY`, exported)
|
|
197
|
+
allows up to `CAUTION`, escalates `ELEVATED_RISK` through `CRITICAL_THREAT` to
|
|
198
|
+
a person, and denies `KNOWN_MALICIOUS` — the one level requiring
|
|
199
|
+
analyst-verified evidence, and one no value justifies signing to.
|
|
126
200
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
201
|
+
## Three behaviours worth knowing before you ship
|
|
202
|
+
|
|
203
|
+
**An unpriced action is denied** when any value rule exists — a per-action cap
|
|
204
|
+
or a spend window. Pass `valueUsd: 0` explicitly if an action genuinely moves
|
|
205
|
+
nothing. For an autonomous signer, "we couldn't price it" must not resolve to
|
|
206
|
+
"so we signed it".
|
|
130
207
|
|
|
131
208
|
**An empty allowlist denies everything**, rather than reading as unconfigured.
|
|
209
|
+
Otherwise `narrowPolicy` could *widen* a policy whenever two allowlists it
|
|
210
|
+
intersected had nothing in common.
|
|
211
|
+
|
|
212
|
+
**An approval with no stated `approvalAmount` is denied.** The size of an
|
|
213
|
+
allowance is the whole of what is being granted, and `unlimited`, `max`, or any
|
|
214
|
+
number at or above 2²⁵⁵ counts as unlimited.
|
|
132
215
|
|
|
133
|
-
## Known limit
|
|
216
|
+
## Known limit: the ledger is in-process
|
|
134
217
|
|
|
135
218
|
The bundled `SpendLedger` is **in-process and in-memory**. Two replicas each
|
|
136
|
-
enforcing $10,000/day enforce $20,000, and a restart resets the
|
|
137
|
-
|
|
138
|
-
|
|
219
|
+
enforcing $10,000/day enforce $20,000 between them, and a restart resets the
|
|
220
|
+
window to zero. Do not deploy a fleet behind it and describe the cap as
|
|
221
|
+
enforced.
|
|
222
|
+
|
|
223
|
+
Fixing it needs no rewrite. `evaluatePolicy` depends only on the two-method
|
|
224
|
+
`AgentUsage` interface, so a Redis- or Postgres-backed implementation replaces
|
|
225
|
+
the class entirely:
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
import { AgentGuard, type AgentUsage } from '@decentrys/agent';
|
|
229
|
+
|
|
230
|
+
const shared: AgentUsage = {
|
|
231
|
+
spentUsdSince: (agentId, sinceMs) => /* … */ 0,
|
|
232
|
+
actionsSince: (agentId, sinceMs) => /* … */ 0,
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const guard = new AgentGuard({ apiKey, policy, ledger: shared });
|
|
236
|
+
guard.reservesBudget; // false — a read-only source cannot take holds
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Implement `ReservationLedger` (`reserve` / `confirm` / `release` on top of
|
|
240
|
+
`AgentUsage`) to keep holds, and `reservesBudget` reports `true`. With a
|
|
241
|
+
read-only source, cumulative caps count settled history only, so two concurrent
|
|
242
|
+
actions that each fit alone can both be admitted.
|
|
243
|
+
|
|
244
|
+
## Errors
|
|
245
|
+
|
|
246
|
+
Nothing on the call path throws — an exception thrown at an agent is a
|
|
247
|
+
condition it handles by retrying, or by taking the branch that skips the guard.
|
|
248
|
+
A `deny` it must read is harder to route around.
|
|
249
|
+
|
|
250
|
+
The constructor throws, on an unsealed policy or on neither an `apiKey` nor a
|
|
251
|
+
`protect` client being supplied. `sealPolicy` throws on a `warn` action, and
|
|
252
|
+
`narrowPolicy` throws when two policies are bound to different agents. All of
|
|
253
|
+
those are wiring errors a human makes at deploy time.
|
|
139
254
|
|
|
140
255
|
## The rest of the SDK
|
|
141
256
|
|
|
@@ -639,7 +639,7 @@ var DecentrysAgent = (() => {
|
|
|
639
639
|
function cacheKey(kind, parts) {
|
|
640
640
|
return [kind, ...parts.map((p) => p === void 0 || p === null ? "" : String(p))].join("|");
|
|
641
641
|
}
|
|
642
|
-
var SDK_VERSION = "0.1.
|
|
642
|
+
var SDK_VERSION = "0.1.2";
|
|
643
643
|
var DEFAULT_BASE_URL = "https://api.decentrys.com";
|
|
644
644
|
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
645
645
|
var DEFAULT_CACHE_TTL_MS = 12e4;
|
|
@@ -1803,7 +1803,7 @@ var DecentrysAgent = (() => {
|
|
|
1803
1803
|
}
|
|
1804
1804
|
|
|
1805
1805
|
// src/client.ts
|
|
1806
|
-
var AGENT_SDK_VERSION = "0.1.
|
|
1806
|
+
var AGENT_SDK_VERSION = "0.1.2";
|
|
1807
1807
|
var DEFAULT_AUDIT_LOG_ENTRIES = 1e3;
|
|
1808
1808
|
var AgentGuard = class _AgentGuard {
|
|
1809
1809
|
protect;
|
|
@@ -597,7 +597,7 @@ var TtlCache = class {
|
|
|
597
597
|
function cacheKey(kind, parts) {
|
|
598
598
|
return [kind, ...parts.map((p) => p === void 0 || p === null ? "" : String(p))].join("|");
|
|
599
599
|
}
|
|
600
|
-
var SDK_VERSION = "0.1.
|
|
600
|
+
var SDK_VERSION = "0.1.2";
|
|
601
601
|
var DEFAULT_BASE_URL = "https://api.decentrys.com";
|
|
602
602
|
var DEFAULT_TIMEOUT_MS = 4e3;
|
|
603
603
|
var DEFAULT_CACHE_TTL_MS = 12e4;
|
|
@@ -1761,7 +1761,7 @@ function symbolFor(outcome) {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
|
|
1763
1763
|
// src/client.ts
|
|
1764
|
-
var AGENT_SDK_VERSION = "0.1.
|
|
1764
|
+
var AGENT_SDK_VERSION = "0.1.2";
|
|
1765
1765
|
var DEFAULT_AUDIT_LOG_ENTRIES = 1e3;
|
|
1766
1766
|
var AgentGuard = class _AgentGuard {
|
|
1767
1767
|
protect;
|
package/dist/client.d.ts
CHANGED
|
@@ -24,7 +24,14 @@ import type { AgentAction, AgentDecision, AgentOutcomeRecord, AgentPolicy } from
|
|
|
24
24
|
import { type SealedPolicy } from './policy';
|
|
25
25
|
import { type AgentUsage, type ReservationLedger } from './ledger';
|
|
26
26
|
import { type AgentActionExplanation } from './explain';
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Sent in the user-agent on every request.
|
|
29
|
+
*
|
|
30
|
+
* Kept in step with package.json by hand — it drifted once already, and a
|
|
31
|
+
* stale value here silently under-reports the real version in server-side
|
|
32
|
+
* telemetry rather than failing in any visible way.
|
|
33
|
+
*/
|
|
34
|
+
export declare const AGENT_SDK_VERSION = "0.1.2";
|
|
28
35
|
export interface AgentGuardConfig {
|
|
29
36
|
/**
|
|
30
37
|
* The operator's policy, already sealed.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACL,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAwB,KAAK,SAAS,EAClF,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,KAAK,YAAY,EAA+C,MAAM,UAAU,CAAC;AAC1F,OAAO,EAC6B,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAC1E,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,sBAAsB,EAAsB,MAAM,WAAW,CAAC;AAE5E,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAIzC,MA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E;IAC3E,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,CAAA;KAAO,GAAG,kBAAkB,GAAG,IAAI;IAMrG,uEAAuE;IACvE,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,CAAA;KAAO,GAAG,kBAAkB,GAAG,IAAI;IAUnG;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,sBAAsB,GAAG,IAAI;IAMxE;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;KAAO,GAAG,UAAU,EAAE;IAO7F;;;;;OAKG;IACH,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU;IAchD;;;;;;OAMG;YACW,MAAM;IA6BpB,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,aAAa;CAItB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIxF"}
|
package/dist/client.js
CHANGED
|
@@ -27,7 +27,14 @@ const protect_1 = require("@decentrys/protect");
|
|
|
27
27
|
const policy_1 = require("./policy");
|
|
28
28
|
const ledger_1 = require("./ledger");
|
|
29
29
|
const explain_1 = require("./explain");
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Sent in the user-agent on every request.
|
|
32
|
+
*
|
|
33
|
+
* Kept in step with package.json by hand — it drifted once already, and a
|
|
34
|
+
* stale value here silently under-reports the real version in server-side
|
|
35
|
+
* telemetry rather than failing in any visible way.
|
|
36
|
+
*/
|
|
37
|
+
exports.AGENT_SDK_VERSION = '0.1.2';
|
|
31
38
|
const DEFAULT_AUDIT_LOG_ENTRIES = 1_000;
|
|
32
39
|
class AgentGuard {
|
|
33
40
|
protect;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAsXH,8CAIC;AAxXD,gDAG4B;AAG5B,qCAA0F;AAC1F,qCAEkB;AAClB,uCAA4E;AAE5E;;;;;;GAMG;AACU,QAAA,iBAAiB,GAAG,OAAO,CAAC;AAEzC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AA4DxC,MAAa,UAAU;IACJ,OAAO,CAAY;IACnB,MAAM,CAAe;IACrB,UAAU,CAAa;IACvB,SAAS,CAA2B;IACpC,YAAY,GAAiB,EAAE,CAAC;IAChC,UAAU,CAAS;IACnB,UAAU,CAAkD;IAE7E,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YACzG,MAAM,IAAI,KAAK,CACb,8FAA8F;kBAC5F,0EAA0E,CAC7E,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC;aAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YAC7C,MAAM,aAAa,GAAoB;gBACrC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,oBAAoB;gBAC7C,mEAAmE;gBACnE,qEAAqE;g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AK,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;QAC1F,IAAI,KAAK;YAAE,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IACrC,CAAC;CACF;AAxRD,gCAwRC;AAED;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAAC,UAAkC;IAClE,IAAI,CAAC,UAAU;QAAE,OAAO,4BAA4B,CAAC;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,sBAAsB,CAAC,CAAC;IACrF,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -59,8 +59,9 @@ export interface AgentAction {
|
|
|
59
59
|
* **`undefined` is not zero.** An action with no value at all (a message
|
|
60
60
|
* signature, a zero-value call) should say `0`; leaving this out means "I do
|
|
61
61
|
* not know what this is worth", and a value cap cannot be enforced against
|
|
62
|
-
* an unknown
|
|
63
|
-
*
|
|
62
|
+
* an unknown, so `evaluatePolicy` denies the action whenever any value rule
|
|
63
|
+
* is configured. For an autonomous signer, "we could not price it" must not
|
|
64
|
+
* resolve to "so we signed it".
|
|
64
65
|
*
|
|
65
66
|
* AgentGuard never prices anything itself. Pricing belongs to whoever runs
|
|
66
67
|
* the agent, with the feed and the staleness rules they are willing to be
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EA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,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;IACtB,oFAAoF;IACpF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;OAMG;IACH,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,wEAAwE;IACxE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,sDAAsD;IACtD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gFAAgF;IAChF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAIU,QAAA,mBAAmB,GAAG,aAAa,CAAC;AAEjD,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E;;;;;;;GAOG;AACU,QAAA,kBAAkB,GAAG;IAChC,UAAU;IACV,MAAM;IACN,SAAS;IACT,eAAe;IACf,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;IACR,cAAc;IACd,SAAS;CACD,CAAC;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAIU,QAAA,mBAAmB,GAAG,aAAa,CAAC;AAEjD,8EAA8E;AAC9E,+BAA+B;AAC/B,8EAA8E;AAE9E;;;;;;;GAOG;AACU,QAAA,kBAAkB,GAAG;IAChC,UAAU;IACV,MAAM;IACN,SAAS;IACT,eAAe;IACf,QAAQ;IACR,OAAO;IACP,SAAS;IACT,QAAQ;IACR,cAAc;IACd,SAAS;CACD,CAAC;AAsLX,gFAAgF;AACnE,QAAA,WAAW,GAAG;IACzB,eAAe;IACf,aAAa;IACb,OAAO;IACP,cAAc;IACd,UAAU;IACV,OAAO;IACP,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,YAAY;IACZ,YAAY;IACZ,yBAAyB;IACzB,0BAA0B;CAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentrys/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "AgentGuard: policy enforcement in front of an autonomous on-chain agent. An agent cannot widen the limits its operator set.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Decentrys Labs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"README.md"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@decentrys/protect": "0.1.
|
|
52
|
+
"@decentrys/protect": "0.1.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"typescript": "^5.7.2",
|
package/src/client.ts
CHANGED
|
@@ -32,7 +32,14 @@ import {
|
|
|
32
32
|
} from './ledger';
|
|
33
33
|
import { type AgentActionExplanation, explainAgentAction } from './explain';
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Sent in the user-agent on every request.
|
|
37
|
+
*
|
|
38
|
+
* Kept in step with package.json by hand — it drifted once already, and a
|
|
39
|
+
* stale value here silently under-reports the real version in server-side
|
|
40
|
+
* telemetry rather than failing in any visible way.
|
|
41
|
+
*/
|
|
42
|
+
export const AGENT_SDK_VERSION = '0.1.2';
|
|
36
43
|
|
|
37
44
|
const DEFAULT_AUDIT_LOG_ENTRIES = 1_000;
|
|
38
45
|
|
package/src/model.ts
CHANGED
|
@@ -78,8 +78,9 @@ export interface AgentAction {
|
|
|
78
78
|
* **`undefined` is not zero.** An action with no value at all (a message
|
|
79
79
|
* signature, a zero-value call) should say `0`; leaving this out means "I do
|
|
80
80
|
* not know what this is worth", and a value cap cannot be enforced against
|
|
81
|
-
* an unknown
|
|
82
|
-
*
|
|
81
|
+
* an unknown, so `evaluatePolicy` denies the action whenever any value rule
|
|
82
|
+
* is configured. For an autonomous signer, "we could not price it" must not
|
|
83
|
+
* resolve to "so we signed it".
|
|
83
84
|
*
|
|
84
85
|
* AgentGuard never prices anything itself. Pricing belongs to whoever runs
|
|
85
86
|
* the agent, with the feed and the staleness rules they are willing to be
|