@tangle-network/agent-gateway 0.6.0 → 0.7.1

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  # @tangle-network/agent-gateway
2
2
 
3
- Hono middleware that turns any Tangle agent app into a paid API. Wrap your chat endpoint to accept API keys, x402 SpendAuth, or MPP credentials — with scope enforcement, per-key rate limits, nonce replay protection, prompt-injection detection, and publish routes for the marketplace.
3
+ Hono middleware that turns any Tangle agent app into a paid API.
4
+ It exposes one shared request pipeline for API keys, x402 SpendAuth, and MPP credentials, with scope enforcement, per-key rate limits, nonce replay protection, prompt-injection detection, and publish routes for the marketplace.
4
5
 
5
6
  ## Install
6
7
 
@@ -11,17 +12,41 @@ npm install @tangle-network/agent-gateway
11
12
  ## Usage
12
13
 
13
14
  ```ts
14
- import { createAgentGateway } from '@tangle-network/agent-gateway'
15
+ import {
16
+ createAgentGateway,
17
+ verifyApiKeyFromStore,
18
+ } from '@tangle-network/agent-gateway'
15
19
  import { Hono } from 'hono'
16
20
 
17
21
  const app = new Hono()
18
- app.use('/chat/*', createAgentGateway({
19
- apiKeyStore: myKeyStore,
20
- x402: { verifierUrl: 'https://router.tangle.tools/x402/verify' },
21
- rateLimits: { perKey: { rpm: 60 } },
22
+ app.route('/v1/agents', createAgentGateway({
23
+ resolveAgent: loadPublishedAgent,
24
+ getSandbox: openAgentSandbox,
25
+ recordUsage: recordUsageEvent,
26
+ x402: {
27
+ operatorAddress: '0x…',
28
+ chainId: 3799,
29
+ verifySigner: verifySpendAuthSignature,
30
+ },
31
+ verifyApiKey: (authHeader) => verifyApiKeyFromStore(authHeader, apiKeyStore),
22
32
  }))
23
33
  ```
24
34
 
35
+ `x402.verifySigner` is required for production.
36
+ Set `x402.demoMode: true` only for local development and tests; that explicit mode also enables the built-in `sk_agent_*` demo key verifier.
37
+
38
+ MPP is method-specific.
39
+ Configure `mpp.verifySigner` for production MPP credentials; it receives the decoded JSON payload when available plus the original decoded credential, and returns the authenticated consumer ID or `null`.
40
+ The default `blueprintevm` method may reuse `x402.verifySigner` when its credential has the compatible x402 payload shape.
41
+ Other methods are not accepted until they have their own verifier.
42
+
43
+ The same authentication, authorization, rate-limit, filtering, sandbox, settlement, and usage-recording pipeline is used by the OpenAI-compatible and A2A endpoints.
44
+ Wire protocol handlers only translate their request and response shapes.
45
+
46
+ ## A2A protocol
47
+
48
+ The gateway speaks Google's A2A protocol alongside its OpenAI-compatible surface: discovery via `.well-known/agent.json`, JSON-RPC 2.0 dispatch for `message/send`, `message/stream`, `tasks/get`, `tasks/cancel`, `tasks/resubscribe`, and the four `tasks/pushNotificationConfig/*` methods. Long-horizon agents — durable tasks across worker restarts, webhook delivery on terminal state, `input-required` pauses with multi-turn continuation — are documented in [`docs/a2a-long-horizon.md`](./docs/a2a-long-horizon.md).
49
+
25
50
  ## Tier
26
51
 
27
52
  Marketplace tier of the [agent-builder](https://github.com/drewstone/tangle-agent-builder) three-tier architecture (Forge / Workbench / Marketplace). Used by every `*.tangle.tools` agent app that publishes a paid API.