@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 +31 -6
- package/dist/chunk-Q4YAIEZY.js +1763 -0
- package/dist/chunk-Q4YAIEZY.js.map +1 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.js +112 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts +2 -2
- package/dist/middleware.js +1 -1
- package/dist/types-DEsMmS-X.d.ts +875 -0
- package/dist/types.d.ts +1 -1
- package/package.json +14 -10
- package/src/a2a/agent-card.ts +55 -0
- package/src/a2a/handler.ts +797 -0
- package/src/a2a/jsonrpc.ts +65 -0
- package/src/a2a/push-notifications.ts +299 -0
- package/src/a2a/task-store-sql.ts +189 -0
- package/src/a2a/task-store.ts +53 -0
- package/src/a2a/translate.ts +77 -0
- package/src/a2a/types.ts +217 -0
- package/src/dispatch.ts +486 -0
- package/src/index.ts +58 -1
- package/src/middleware.ts +139 -294
- package/src/types.ts +76 -2
- package/src/verify.ts +93 -26
- package/dist/chunk-373QHRKV.js +0 -635
- package/dist/chunk-373QHRKV.js.map +0 -1
- package/dist/types-C_L7yXXI.d.ts +0 -362
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.
|
|
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 {
|
|
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.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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.
|