agentadmit 1.7.0 → 1.8.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.
- checksums.yaml +4 -4
- data/README.md +25 -1
- data/lib/agentadmit/introspection_client.rb +15 -2
- data/lib/agentadmit/tokens_client.rb +28 -2
- data/lib/agentadmit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9903cf0e0365cc82696a35748e5736582e4d2e9aad33e9c956c62df61c4c5eea
|
|
4
|
+
data.tar.gz: e1cbbc38ef3ca551b003574383e759056f3c6f90c2224fc4cd8dc68af836c270
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3089318cad6fd8c1914a3f087b9e9e2351ee0131b81d6bd288a9fa736868ce6c64937de4a248c0c3c4162c2d4b481e044ef2c642d917d368499e42dd6a72e93
|
|
7
|
+
data.tar.gz: 2f2d55a5ea98bc761ccabd6cce0e3e5ac417b0b5b659094c05ca74178abd77752e392c6b6104621ab750ba97aa1264f5b4d541e47c4a243e20b037b1417b69ab
|
data/README.md
CHANGED
|
@@ -258,7 +258,7 @@ config = alerts.get_alert_config(app_id: 'app_abc123')
|
|
|
258
258
|
AgentAdmit detects anomalies, fires alerts, and (with kill switch) auto-revokes connections. **How you notify your own users is up to you.** AgentAdmit provides the data -- you deliver it through your own system (in-app notifications, email, push, etc.).
|
|
259
259
|
|
|
260
260
|
- **Poll alerts** -- Use the SDK methods above from your backend to check for new events, then notify users through your existing system.
|
|
261
|
-
- **Webhook delivery** -- Configure a webhook URL in your AgentAdmit dashboard. When an alert fires, AgentAdmit POSTs the payload to your server, signed with your `whsec_...` secret. Always verify the signature against the raw request body before trusting the payload:
|
|
261
|
+
- **Webhook delivery** -- Configure a webhook URL in your AgentAdmit dashboard. When an alert fires, AgentAdmit POSTs the payload to your server, signed with your `whsec_...` secret. The payload carries `alert_id`, `alert_type`, `severity`, the connection's `agent_label`, and the grant's declared `purpose`; the full shape is documented in the Webhook Delivery section of the MCP guide at https://agentadmit.com/docs/mcp-guide. Always verify the signature against the raw request body before trusting the payload:
|
|
262
262
|
|
|
263
263
|
```ruby
|
|
264
264
|
# Rails controller
|
|
@@ -325,3 +325,27 @@ result.purpose # => "Book quarterly travel for the sales team" or nil
|
|
|
325
325
|
```
|
|
326
326
|
|
|
327
327
|
`purpose` is nullable -- connections issued without one (or by servers that predate the field) read as `nil`. Do not branch authorization on it; keep enforcement on scopes, connection status, and consent.
|
|
328
|
+
|
|
329
|
+
### User-declared intent
|
|
330
|
+
|
|
331
|
+
User-declared intent: the user's OWN words, typed at the consent moment. `purpose` is the app's words for why the connection exists; `user_intent` is what the user actually said they wanted ("build me a weekly workout summary"). On the hosted consent page the user can type it into an optional field; apps collecting consent in their own UI can pass it at token issuance.
|
|
332
|
+
|
|
333
|
+
Pass it when issuing a connection token (optional, 1-300 characters; a malformed value -- non-string, empty, or over 300 characters -- normalizes to `nil` and is omitted from the request rather than rejected):
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
issued = tokens.issue_token(
|
|
337
|
+
user_id: "user_42",
|
|
338
|
+
scopes: ["read:orders"],
|
|
339
|
+
purpose: "Book quarterly travel for the sales team",
|
|
340
|
+
user_intent: "Book my flights to the Austin offsite in October"
|
|
341
|
+
)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
It flows exactly like purpose: stored on the connection, returned by verify, stamped into every audit row, and carried on grant and revocation ledger events. When the hosted presence ceremony runs, the user's own words are included in the verifiable-consent-evidence commitment, so their authenticator signs what they said they wanted.
|
|
345
|
+
|
|
346
|
+
```ruby
|
|
347
|
+
result = AgentAdmit::IntrospectionClient.new.verify(token)
|
|
348
|
+
result.user_intent # => "Book my flights to the Austin offsite in October" or nil
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
`user_intent` is nullable -- connections issued without one (or by servers that predate the field) read as `nil`. Months later, a review screen can answer "is this still appropriate?" with the user's own stated boundary, not just the app's. Like purpose, it is a review-time record and never an enforcement input; authorization decisions ride scopes, connection status, and consent.
|
|
@@ -17,7 +17,7 @@ module AgentAdmit
|
|
|
17
17
|
|
|
18
18
|
IntrospectionResult = Struct.new(:user_id, :connection_id, :scopes, :agent_label,
|
|
19
19
|
:sub, :role, :app_id, :jti, :exp, :consent,
|
|
20
|
-
:presence, :purpose, keyword_init: true) do
|
|
20
|
+
:presence, :purpose, :user_intent, keyword_init: true) do
|
|
21
21
|
def has_scope?(scope)
|
|
22
22
|
scopes.include?(scope)
|
|
23
23
|
end
|
|
@@ -52,6 +52,12 @@ module AgentAdmit
|
|
|
52
52
|
# reason recorded on the grant at the consent moment. Review-time record
|
|
53
53
|
# only, never an enforcement input; authorization decisions ride scopes,
|
|
54
54
|
# connection status, and consent.
|
|
55
|
+
|
|
56
|
+
# `user_intent` (String or nil) is the user-declared intent: the user's
|
|
57
|
+
# OWN words, typed at the consent moment (purpose is the app's words;
|
|
58
|
+
# user_intent is the user's). Review-time record only, never an
|
|
59
|
+
# enforcement input; authorization decisions ride scopes, connection
|
|
60
|
+
# status, and consent.
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
def initialize(config = nil)
|
|
@@ -188,6 +194,12 @@ module AgentAdmit
|
|
|
188
194
|
purpose = data["purpose"]
|
|
189
195
|
purpose = nil unless purpose.is_a?(String)
|
|
190
196
|
|
|
197
|
+
# User-declared intent passes through the same way (the hosted
|
|
198
|
+
# /verify returns it nullable). Review-time record, never an
|
|
199
|
+
# enforcement input, so a malformed value is simply dropped.
|
|
200
|
+
user_intent = data["user_intent"]
|
|
201
|
+
user_intent = nil unless user_intent.is_a?(String)
|
|
202
|
+
|
|
191
203
|
return IntrospectionResult.new(
|
|
192
204
|
user_id: data["user_id"],
|
|
193
205
|
connection_id: data["connection_id"],
|
|
@@ -200,7 +212,8 @@ module AgentAdmit
|
|
|
200
212
|
exp: data["exp"],
|
|
201
213
|
consent: consent,
|
|
202
214
|
presence: presence,
|
|
203
|
-
purpose: purpose
|
|
215
|
+
purpose: purpose,
|
|
216
|
+
user_intent: user_intent
|
|
204
217
|
)
|
|
205
218
|
end
|
|
206
219
|
|
|
@@ -18,6 +18,10 @@ module AgentAdmit
|
|
|
18
18
|
# Maximum length of a declared purpose (matches the hosted API contract).
|
|
19
19
|
PURPOSE_MAX_LENGTH = 300
|
|
20
20
|
|
|
21
|
+
# Maximum length of a user-declared intent (matches the hosted API
|
|
22
|
+
# contract: optional string, 1..300 characters).
|
|
23
|
+
USER_INTENT_MAX_LENGTH = 300
|
|
24
|
+
|
|
21
25
|
def initialize(config = nil)
|
|
22
26
|
@config = config || AgentAdmit.configuration || Config.new
|
|
23
27
|
@config.validate_api_key!
|
|
@@ -42,19 +46,41 @@ module AgentAdmit
|
|
|
42
46
|
# never an enforcement input; authorization decisions ride scopes,
|
|
43
47
|
# connection status, and consent. Max 300 characters; omitted from the
|
|
44
48
|
# request when nil.
|
|
49
|
+
# @param user_intent [String, nil] user-declared intent: the user's OWN
|
|
50
|
+
# words, typed at the consent moment (distinct from purpose, which is
|
|
51
|
+
# the app's words). Optional, 1-300 characters. Validated like purpose:
|
|
52
|
+
# a non-String, non-nil value or a string over 300 characters raises
|
|
53
|
+
# ArgumentError before any request is sent — silently discarding the
|
|
54
|
+
# user's typed words would be data loss. Empty/whitespace-only strings
|
|
55
|
+
# normalize to nil and are omitted. Like purpose, it is a review-time
|
|
56
|
+
# record, never an enforcement input.
|
|
45
57
|
# @return [Hash] the issue response — "token" is the self-describing
|
|
46
58
|
# ag_ct_… connection token to hand to the user's agent
|
|
47
|
-
# @raise [ArgumentError] if purpose exceeds 300 characters
|
|
59
|
+
# @raise [ArgumentError] if purpose exceeds 300 characters, or if
|
|
60
|
+
# user_intent is a non-String (other than nil) or exceeds 300 characters
|
|
48
61
|
# @raise [IntrospectionError] if issuance fails
|
|
49
62
|
#
|
|
50
|
-
def issue_token(user_id:, scopes:, role: nil, duration_seconds: UNSET, purpose: nil
|
|
63
|
+
def issue_token(user_id:, scopes:, role: nil, duration_seconds: UNSET, purpose: nil,
|
|
64
|
+
user_intent: nil)
|
|
51
65
|
if purpose && purpose.length > PURPOSE_MAX_LENGTH
|
|
52
66
|
raise ArgumentError, "purpose must be at most #{PURPOSE_MAX_LENGTH} characters"
|
|
53
67
|
end
|
|
54
68
|
|
|
69
|
+
# User-declared intent is validated like purpose: reject out-of-contract
|
|
70
|
+
# values before any request rather than silently discarding the user's
|
|
71
|
+
# typed words (data loss). Empty/whitespace-only normalizes to nil-omit.
|
|
72
|
+
unless user_intent.nil? || user_intent.is_a?(String)
|
|
73
|
+
raise ArgumentError, "user_intent must be a String or nil"
|
|
74
|
+
end
|
|
75
|
+
if user_intent && user_intent.length > USER_INTENT_MAX_LENGTH
|
|
76
|
+
raise ArgumentError, "user_intent must be at most #{USER_INTENT_MAX_LENGTH} characters"
|
|
77
|
+
end
|
|
78
|
+
user_intent = nil if user_intent && user_intent.strip.empty?
|
|
79
|
+
|
|
55
80
|
body = { "user_id" => user_id, "scopes" => scopes }
|
|
56
81
|
body["role"] = role if role
|
|
57
82
|
body["purpose"] = purpose if purpose
|
|
83
|
+
body["user_intent"] = user_intent if user_intent
|
|
58
84
|
# Tri-state: the UNSET sentinel omits the key entirely; nil survives
|
|
59
85
|
# JSON.generate as explicit JSON null (no compact, no nil-guard).
|
|
60
86
|
body["duration_seconds"] = duration_seconds unless duration_seconds.equal?(UNSET)
|
data/lib/agentadmit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: agentadmit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christopher Emerson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|