@agentlayer.tech/wallet 0.1.101 → 0.1.103
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/.claude-plugin/marketplace.json +4 -1
- package/.openclaw/extensions/agent-wallet/dist/index.js +46 -1
- package/.openclaw/extensions/agent-wallet/index.ts +46 -1
- package/.openclaw/extensions/agent-wallet/openclaw.plugin.json +1 -1
- package/.openclaw/extensions/agent-wallet/package.json +1 -1
- package/README.md +18 -0
- package/VERSION +1 -1
- package/agent-wallet/agent_wallet/__init__.py +1 -1
- package/agent-wallet/agent_wallet/connector_cli.py +198 -0
- package/agent-wallet/agent_wallet/connectors/__init__.py +28 -0
- package/agent-wallet/agent_wallet/connectors/catalog.py +68 -0
- package/agent-wallet/agent_wallet/connectors/client.py +308 -0
- package/agent-wallet/agent_wallet/connectors/intent_policy.py +243 -0
- package/agent-wallet/agent_wallet/connectors/manifest.py +192 -0
- package/agent-wallet/agent_wallet/connectors/registry.py +341 -0
- package/agent-wallet/agent_wallet/openclaw_adapter.py +56 -5
- package/agent-wallet/openclaw.plugin.json +1 -1
- package/agent-wallet/pyproject.toml +4 -2
- package/agent-wallet/scripts/build_release_bundle.py +1 -0
- package/agent-wallet/scripts/install_agent_wallet.py +1 -1
- package/bin/openclaw-agent-wallet.mjs +38 -0
- package/claude-code/plugins/agent-wallet/.claude-plugin/plugin.json +2 -2
- package/claude-code/plugins/agent-wallet/commands/wallet-evm.md +1 -0
- package/claude-code/plugins/agent-wallet/commands/wallet-setup.md +1 -0
- package/claude-code/plugins/agent-wallet/skills/wallet-operator/SKILL.md +1 -0
- package/codex/plugins/agent-wallet/.codex-plugin/plugin.json +1 -1
- package/codex/plugins/agent-wallet/server.py +4 -1
- package/connectors/AGENTS.md +37 -0
- package/connectors/DEVELOPER_GUIDE.md +131 -0
- package/connectors/README.md +139 -0
- package/connectors/READ_ONLY_BETA.md +54 -0
- package/connectors/RELEASING.md +48 -0
- package/connectors/conformance/README.md +31 -0
- package/connectors/conformance/package.json +54 -0
- package/connectors/conformance/scripts/sync-license.mjs +3 -0
- package/connectors/conformance/scripts/sync-spec.mjs +16 -0
- package/connectors/conformance/src/cli.ts +43 -0
- package/connectors/conformance/src/index.ts +7 -0
- package/connectors/conformance/src/runner.ts +314 -0
- package/connectors/conformance/src/types.ts +27 -0
- package/connectors/conformance/test/fixtures/invalid-response-identity.json +14 -0
- package/connectors/conformance/test/fixtures/missing-tool-fixture.json +4 -0
- package/connectors/conformance/test/runner.test.mjs +151 -0
- package/connectors/conformance/tsconfig.json +17 -0
- package/connectors/examples/reference-crypto-data/Dockerfile +21 -0
- package/connectors/examples/reference-crypto-data/README.md +51 -0
- package/connectors/examples/reference-crypto-data/conformance.json +11 -0
- package/connectors/examples/reference-crypto-data/connector.json +95 -0
- package/connectors/examples/reference-crypto-data/package.json +21 -0
- package/connectors/examples/reference-crypto-data/railway.toml +9 -0
- package/connectors/examples/reference-crypto-data/src/connector.ts +137 -0
- package/connectors/examples/reference-crypto-data/src/server.ts +13 -0
- package/connectors/examples/reference-crypto-data/test/connector.test.mjs +97 -0
- package/connectors/examples/reference-crypto-data/tsconfig.json +17 -0
- package/connectors/package-lock.json +561 -0
- package/connectors/package.json +19 -0
- package/connectors/scripts/smoke-packed-packages.mjs +121 -0
- package/connectors/sdk-typescript/README.md +47 -0
- package/connectors/sdk-typescript/package.json +49 -0
- package/connectors/sdk-typescript/scripts/sync-license.mjs +3 -0
- package/connectors/sdk-typescript/src/connector.ts +204 -0
- package/connectors/sdk-typescript/src/errors.ts +11 -0
- package/connectors/sdk-typescript/src/http.ts +116 -0
- package/connectors/sdk-typescript/src/index.ts +26 -0
- package/connectors/sdk-typescript/src/types.ts +101 -0
- package/connectors/sdk-typescript/test/sdk.test.mjs +181 -0
- package/connectors/sdk-typescript/tsconfig.json +21 -0
- package/connectors/spec/connector-manifest.schema.json +340 -0
- package/connectors/spec/connector-protocol.md +159 -0
- package/connectors/spec/transaction-intent.schema.json +281 -0
- package/connectors/templates/read-only/.env.example +1 -0
- package/connectors/templates/read-only/Dockerfile +11 -0
- package/connectors/templates/read-only/README.md +33 -0
- package/connectors/templates/read-only/conformance.json +11 -0
- package/connectors/templates/read-only/connector.json +64 -0
- package/connectors/templates/read-only/package.json +21 -0
- package/connectors/templates/read-only/railway.toml +9 -0
- package/connectors/templates/read-only/src/connector.ts +61 -0
- package/connectors/templates/read-only/src/server.ts +14 -0
- package/connectors/templates/read-only/test/connector.test.mjs +62 -0
- package/connectors/templates/read-only/tsconfig.json +17 -0
- package/hermes/plugins/agent_wallet/plugin.yaml +1 -1
- package/package.json +2 -1
- package/wdk-btc-wallet/package.json +1 -1
- package/wdk-evm-wallet/package.json +1 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://agent-layer.tech/schemas/connectors/v1/transaction-intent.schema.json",
|
|
4
|
+
"title": "AgentLayer Connector Transaction Intent v1",
|
|
5
|
+
"oneOf": [
|
|
6
|
+
{
|
|
7
|
+
"$ref": "#/$defs/evmIntent"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"$ref": "#/$defs/solanaIntent"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"$defs": {
|
|
14
|
+
"uintString": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^(0|[1-9][0-9]*)$",
|
|
17
|
+
"maxLength": 80
|
|
18
|
+
},
|
|
19
|
+
"digest": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
22
|
+
},
|
|
23
|
+
"evmAddress": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"pattern": "^0x[0-9a-fA-F]{40}$"
|
|
26
|
+
},
|
|
27
|
+
"solanaAddress": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
|
|
30
|
+
},
|
|
31
|
+
"expectedEffect": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"additionalProperties": false,
|
|
34
|
+
"required": ["type", "asset", "direction", "amount"],
|
|
35
|
+
"properties": {
|
|
36
|
+
"type": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"enum": ["asset", "debt", "position", "protocol_fee", "network_fee"]
|
|
39
|
+
},
|
|
40
|
+
"asset": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 1,
|
|
43
|
+
"maxLength": 128
|
|
44
|
+
},
|
|
45
|
+
"direction": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"enum": ["debit", "credit", "increase", "decrease"]
|
|
48
|
+
},
|
|
49
|
+
"amount": {
|
|
50
|
+
"$ref": "#/$defs/uintString"
|
|
51
|
+
},
|
|
52
|
+
"recipient": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"minLength": 1,
|
|
55
|
+
"maxLength": 128
|
|
56
|
+
},
|
|
57
|
+
"description": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"maxLength": 300
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"baseIntent": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"required": [
|
|
66
|
+
"protocol_version",
|
|
67
|
+
"connector_id",
|
|
68
|
+
"connector_version",
|
|
69
|
+
"artifact_digest",
|
|
70
|
+
"tool",
|
|
71
|
+
"quote_fingerprint",
|
|
72
|
+
"expires_at",
|
|
73
|
+
"expected_effects"
|
|
74
|
+
],
|
|
75
|
+
"properties": {
|
|
76
|
+
"protocol_version": {
|
|
77
|
+
"const": 1
|
|
78
|
+
},
|
|
79
|
+
"connector_id": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"pattern": "^[a-z0-9]+(?:[._-][a-z0-9]+)+$",
|
|
82
|
+
"maxLength": 128
|
|
83
|
+
},
|
|
84
|
+
"connector_version": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"maxLength": 64
|
|
87
|
+
},
|
|
88
|
+
"artifact_digest": {
|
|
89
|
+
"$ref": "#/$defs/digest"
|
|
90
|
+
},
|
|
91
|
+
"tool": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"pattern": "^[a-z][a-z0-9_]{1,63}$"
|
|
94
|
+
},
|
|
95
|
+
"quote_fingerprint": {
|
|
96
|
+
"$ref": "#/$defs/digest"
|
|
97
|
+
},
|
|
98
|
+
"expires_at": {
|
|
99
|
+
"type": "string",
|
|
100
|
+
"format": "date-time"
|
|
101
|
+
},
|
|
102
|
+
"expected_effects": {
|
|
103
|
+
"type": "array",
|
|
104
|
+
"minItems": 1,
|
|
105
|
+
"maxItems": 64,
|
|
106
|
+
"items": {
|
|
107
|
+
"$ref": "#/$defs/expectedEffect"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"evmCall": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"additionalProperties": false,
|
|
115
|
+
"required": ["to", "data", "value_wei"],
|
|
116
|
+
"properties": {
|
|
117
|
+
"to": {
|
|
118
|
+
"$ref": "#/$defs/evmAddress"
|
|
119
|
+
},
|
|
120
|
+
"data": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"pattern": "^0x(?:[0-9a-fA-F]{2})*$",
|
|
123
|
+
"maxLength": 262146
|
|
124
|
+
},
|
|
125
|
+
"value_wei": {
|
|
126
|
+
"$ref": "#/$defs/uintString"
|
|
127
|
+
},
|
|
128
|
+
"purpose": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"maxLength": 200
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"evmApproval": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"additionalProperties": false,
|
|
137
|
+
"required": ["token", "spender", "amount_raw"],
|
|
138
|
+
"properties": {
|
|
139
|
+
"token": {
|
|
140
|
+
"$ref": "#/$defs/evmAddress"
|
|
141
|
+
},
|
|
142
|
+
"spender": {
|
|
143
|
+
"$ref": "#/$defs/evmAddress"
|
|
144
|
+
},
|
|
145
|
+
"amount_raw": {
|
|
146
|
+
"$ref": "#/$defs/uintString"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"evmIntent": {
|
|
151
|
+
"allOf": [
|
|
152
|
+
{
|
|
153
|
+
"$ref": "#/$defs/baseIntent"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"type": "object",
|
|
157
|
+
"additionalProperties": false,
|
|
158
|
+
"required": [
|
|
159
|
+
"protocol_version",
|
|
160
|
+
"connector_id",
|
|
161
|
+
"connector_version",
|
|
162
|
+
"artifact_digest",
|
|
163
|
+
"tool",
|
|
164
|
+
"quote_fingerprint",
|
|
165
|
+
"expires_at",
|
|
166
|
+
"expected_effects",
|
|
167
|
+
"kind",
|
|
168
|
+
"chain_id",
|
|
169
|
+
"from",
|
|
170
|
+
"calls",
|
|
171
|
+
"approvals"
|
|
172
|
+
],
|
|
173
|
+
"properties": {
|
|
174
|
+
"protocol_version": true,
|
|
175
|
+
"connector_id": true,
|
|
176
|
+
"connector_version": true,
|
|
177
|
+
"artifact_digest": true,
|
|
178
|
+
"tool": true,
|
|
179
|
+
"quote_fingerprint": true,
|
|
180
|
+
"expires_at": true,
|
|
181
|
+
"expected_effects": true,
|
|
182
|
+
"kind": {
|
|
183
|
+
"const": "evm_transaction_intent"
|
|
184
|
+
},
|
|
185
|
+
"chain_id": {
|
|
186
|
+
"type": "integer",
|
|
187
|
+
"minimum": 1
|
|
188
|
+
},
|
|
189
|
+
"from": {
|
|
190
|
+
"$ref": "#/$defs/evmAddress"
|
|
191
|
+
},
|
|
192
|
+
"calls": {
|
|
193
|
+
"type": "array",
|
|
194
|
+
"minItems": 1,
|
|
195
|
+
"maxItems": 16,
|
|
196
|
+
"items": {
|
|
197
|
+
"$ref": "#/$defs/evmCall"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
"approvals": {
|
|
201
|
+
"type": "array",
|
|
202
|
+
"maxItems": 16,
|
|
203
|
+
"items": {
|
|
204
|
+
"$ref": "#/$defs/evmApproval"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
"solanaIntent": {
|
|
212
|
+
"allOf": [
|
|
213
|
+
{
|
|
214
|
+
"$ref": "#/$defs/baseIntent"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "object",
|
|
218
|
+
"additionalProperties": false,
|
|
219
|
+
"required": [
|
|
220
|
+
"protocol_version",
|
|
221
|
+
"connector_id",
|
|
222
|
+
"connector_version",
|
|
223
|
+
"artifact_digest",
|
|
224
|
+
"tool",
|
|
225
|
+
"quote_fingerprint",
|
|
226
|
+
"expires_at",
|
|
227
|
+
"expected_effects",
|
|
228
|
+
"kind",
|
|
229
|
+
"network",
|
|
230
|
+
"fee_payer",
|
|
231
|
+
"transaction_base64",
|
|
232
|
+
"program_ids"
|
|
233
|
+
],
|
|
234
|
+
"properties": {
|
|
235
|
+
"protocol_version": true,
|
|
236
|
+
"connector_id": true,
|
|
237
|
+
"connector_version": true,
|
|
238
|
+
"artifact_digest": true,
|
|
239
|
+
"tool": true,
|
|
240
|
+
"quote_fingerprint": true,
|
|
241
|
+
"expires_at": true,
|
|
242
|
+
"expected_effects": true,
|
|
243
|
+
"kind": {
|
|
244
|
+
"const": "solana_transaction_intent"
|
|
245
|
+
},
|
|
246
|
+
"network": {
|
|
247
|
+
"type": "string",
|
|
248
|
+
"enum": ["mainnet", "devnet", "testnet"]
|
|
249
|
+
},
|
|
250
|
+
"fee_payer": {
|
|
251
|
+
"$ref": "#/$defs/solanaAddress"
|
|
252
|
+
},
|
|
253
|
+
"transaction_base64": {
|
|
254
|
+
"type": "string",
|
|
255
|
+
"minLength": 1,
|
|
256
|
+
"maxLength": 524288,
|
|
257
|
+
"contentEncoding": "base64"
|
|
258
|
+
},
|
|
259
|
+
"program_ids": {
|
|
260
|
+
"type": "array",
|
|
261
|
+
"minItems": 1,
|
|
262
|
+
"maxItems": 64,
|
|
263
|
+
"uniqueItems": true,
|
|
264
|
+
"items": {
|
|
265
|
+
"$ref": "#/$defs/solanaAddress"
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"required_accounts": {
|
|
269
|
+
"type": "array",
|
|
270
|
+
"maxItems": 128,
|
|
271
|
+
"uniqueItems": true,
|
|
272
|
+
"items": {
|
|
273
|
+
"$ref": "#/$defs/solanaAddress"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
UPSTREAM_API_URL=https://api.example.com
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
FROM node:24-alpine AS build
|
|
2
|
+
WORKDIR /app/connectors
|
|
3
|
+
COPY connectors/ /app/connectors/
|
|
4
|
+
RUN npm ci && npm run build --workspace @agentlayer.tech/read-only-connector-template
|
|
5
|
+
|
|
6
|
+
FROM node:24-alpine
|
|
7
|
+
ENV NODE_ENV=production
|
|
8
|
+
WORKDIR /app/connectors
|
|
9
|
+
COPY --from=build /app /app
|
|
10
|
+
USER node
|
|
11
|
+
CMD ["npm", "run", "start", "--workspace", "@agentlayer.tech/read-only-connector-template"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# AgentLayer read-only connector template
|
|
2
|
+
|
|
3
|
+
This is a minimal TypeScript connector suitable for an isolated Railway
|
|
4
|
+
service. It exposes `GET /healthz` and `POST /invoke` through the AgentLayer
|
|
5
|
+
Connector SDK.
|
|
6
|
+
|
|
7
|
+
## Customize
|
|
8
|
+
|
|
9
|
+
1. Change the connector identity, publisher, deployment URL, allowed upstream
|
|
10
|
+
hosts, tools, and schemas in `connector.json`.
|
|
11
|
+
2. Replace the example handler in `src/connector.ts`.
|
|
12
|
+
3. Keep every community tool read-only and keep `transaction_intents: false`.
|
|
13
|
+
4. Add tests for normalization and every declared output shape.
|
|
14
|
+
|
|
15
|
+
From the repository's `connectors/` directory:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install
|
|
19
|
+
npm run check --workspace @agentlayer.tech/read-only-connector-template
|
|
20
|
+
npm run start --workspace @agentlayer.tech/read-only-connector-template
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
After deployment, replace `transport.url`, run the conformance suite, then
|
|
24
|
+
install the manifest locally with:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
wallet connectors inspect ./connector.json
|
|
28
|
+
wallet connectors install ./connector.json --enable --yes
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Never put upstream credentials in `connector.json`. Configure them as Railway
|
|
32
|
+
service variables and keep `permissions.network_hosts` limited to exact public
|
|
33
|
+
HTTPS hosts.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"id": "com.example.defi-markets",
|
|
4
|
+
"name": "Example DeFi Markets",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"publisher": {
|
|
7
|
+
"id": "example",
|
|
8
|
+
"name": "Example Publisher",
|
|
9
|
+
"url": "https://example.com"
|
|
10
|
+
},
|
|
11
|
+
"agentlayer": {
|
|
12
|
+
"protocol_version": 1,
|
|
13
|
+
"runtime_range": ">=0.1.101"
|
|
14
|
+
},
|
|
15
|
+
"trust": "community_read_only",
|
|
16
|
+
"transport": {
|
|
17
|
+
"type": "https",
|
|
18
|
+
"url": "https://replace-me.up.railway.app",
|
|
19
|
+
"timeout_ms": 10000
|
|
20
|
+
},
|
|
21
|
+
"permissions": {
|
|
22
|
+
"wallet_address": false,
|
|
23
|
+
"transaction_intents": false,
|
|
24
|
+
"network_hosts": ["api.example.com"]
|
|
25
|
+
},
|
|
26
|
+
"tools": [
|
|
27
|
+
{
|
|
28
|
+
"name": "get_pools",
|
|
29
|
+
"description": "List public DeFi pools from the configured upstream API.",
|
|
30
|
+
"read_only": true,
|
|
31
|
+
"risk_level": "low",
|
|
32
|
+
"input_schema": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"properties": {
|
|
35
|
+
"chain": { "type": "string", "minLength": 1, "maxLength": 64 },
|
|
36
|
+
"limit": { "type": "integer", "minimum": 1, "maximum": 50 }
|
|
37
|
+
},
|
|
38
|
+
"required": ["chain"],
|
|
39
|
+
"additionalProperties": false
|
|
40
|
+
},
|
|
41
|
+
"output_schema": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"pools": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"properties": {
|
|
49
|
+
"id": { "type": "string" },
|
|
50
|
+
"symbol": { "type": "string" },
|
|
51
|
+
"apy": { "type": ["number", "null"] },
|
|
52
|
+
"tvl_usd": { "type": ["number", "null"] }
|
|
53
|
+
},
|
|
54
|
+
"required": ["id", "symbol", "apy", "tvl_usd"],
|
|
55
|
+
"additionalProperties": false
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"required": ["pools"],
|
|
60
|
+
"additionalProperties": false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentlayer.tech/read-only-connector-template",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=24"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json",
|
|
11
|
+
"start": "node dist/server.js",
|
|
12
|
+
"check": "npm run build && node --test test/*.test.mjs"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@agentlayer.tech/connector-sdk": "0.1.0-beta.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^24.0.0",
|
|
19
|
+
"typescript": "^7.0.2"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
defineReadOnlyConnector,
|
|
5
|
+
type ConnectorManifest,
|
|
6
|
+
type JsonObject,
|
|
7
|
+
} from "@agentlayer.tech/connector-sdk";
|
|
8
|
+
|
|
9
|
+
const manifest = JSON.parse(
|
|
10
|
+
readFileSync(new URL("../connector.json", import.meta.url), "utf8")
|
|
11
|
+
) as ConnectorManifest;
|
|
12
|
+
|
|
13
|
+
function numberOrNull(value: unknown): number | null {
|
|
14
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizePool(value: unknown): JsonObject | null {
|
|
18
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
19
|
+
const pool = value as Record<string, unknown>;
|
|
20
|
+
if (typeof pool.id !== "string" || typeof pool.symbol !== "string") return null;
|
|
21
|
+
return {
|
|
22
|
+
id: pool.id,
|
|
23
|
+
symbol: pool.symbol,
|
|
24
|
+
apy: numberOrNull(pool.apy),
|
|
25
|
+
tvl_usd: numberOrNull(pool.tvl_usd),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function getPools(arguments_: JsonObject): Promise<JsonObject> {
|
|
30
|
+
const rawBaseUrl = process.env.UPSTREAM_API_URL ?? "https://api.example.com";
|
|
31
|
+
const baseUrl = new URL(rawBaseUrl);
|
|
32
|
+
if (
|
|
33
|
+
baseUrl.protocol !== "https:" ||
|
|
34
|
+
!manifest.permissions.network_hosts.includes(baseUrl.hostname)
|
|
35
|
+
) {
|
|
36
|
+
throw new Error("UPSTREAM_API_URL must be HTTPS and declared in permissions.network_hosts.");
|
|
37
|
+
}
|
|
38
|
+
const url = new URL("/v1/pools", baseUrl);
|
|
39
|
+
url.searchParams.set("chain", String(arguments_.chain));
|
|
40
|
+
url.searchParams.set("limit", String(arguments_.limit ?? 20));
|
|
41
|
+
const response = await fetch(url, {
|
|
42
|
+
headers: { accept: "application/json" },
|
|
43
|
+
redirect: "error",
|
|
44
|
+
signal: AbortSignal.timeout(5000),
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) throw new Error(`Upstream returned HTTP ${response.status}.`);
|
|
47
|
+
const payload: unknown = await response.json();
|
|
48
|
+
const rawPools =
|
|
49
|
+
payload && typeof payload === "object" && !Array.isArray(payload)
|
|
50
|
+
? (payload as Record<string, unknown>).pools
|
|
51
|
+
: null;
|
|
52
|
+
if (!Array.isArray(rawPools)) throw new Error("Upstream response is missing pools.");
|
|
53
|
+
const limit = Number(arguments_.limit ?? 20);
|
|
54
|
+
return { pools: rawPools.map(normalizePool).filter((pool) => pool !== null).slice(0, limit) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const connector = defineReadOnlyConnector({
|
|
58
|
+
manifest,
|
|
59
|
+
handlers: { get_pools: getPools },
|
|
60
|
+
responseTtlSeconds: 60,
|
|
61
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { startConnectorServer } from "@agentlayer.tech/connector-sdk";
|
|
2
|
+
|
|
3
|
+
import { connector } from "./connector.js";
|
|
4
|
+
|
|
5
|
+
const server = await startConnectorServer(connector);
|
|
6
|
+
const address = server.address();
|
|
7
|
+
console.log(
|
|
8
|
+
JSON.stringify({
|
|
9
|
+
event: "connector_started",
|
|
10
|
+
connector_id: connector.manifest.id,
|
|
11
|
+
connector_version: connector.manifest.version,
|
|
12
|
+
address,
|
|
13
|
+
})
|
|
14
|
+
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { connector } from "../dist/connector.js";
|
|
5
|
+
|
|
6
|
+
test("normalizes upstream data into the declared output schema", async () => {
|
|
7
|
+
const previousFetch = globalThis.fetch;
|
|
8
|
+
const previousUrl = process.env.UPSTREAM_API_URL;
|
|
9
|
+
process.env.UPSTREAM_API_URL = "https://api.example.com";
|
|
10
|
+
globalThis.fetch = async (url, options) => {
|
|
11
|
+
assert.equal(url.hostname, "api.example.com");
|
|
12
|
+
assert.equal(url.searchParams.get("chain"), "base");
|
|
13
|
+
assert.equal(options.redirect, "error");
|
|
14
|
+
return new Response(
|
|
15
|
+
JSON.stringify({
|
|
16
|
+
pools: [
|
|
17
|
+
{ id: "pool-1", symbol: "USDC", apy: 5.2, tvl_usd: 1000000, ignored: true },
|
|
18
|
+
{ id: 123, symbol: "invalid" },
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
{ status: 200, headers: { "content-type": "application/json" } }
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
const result = await connector.invoke({
|
|
26
|
+
protocol_version: 1,
|
|
27
|
+
request_id: "template-request-1",
|
|
28
|
+
connector: { id: connector.manifest.id, version: connector.manifest.version },
|
|
29
|
+
tool: "get_pools",
|
|
30
|
+
arguments: { chain: "base", limit: 10 },
|
|
31
|
+
context: { chain: "evm", network: "base" },
|
|
32
|
+
});
|
|
33
|
+
assert.deepEqual(result.result, {
|
|
34
|
+
pools: [{ id: "pool-1", symbol: "USDC", apy: 5.2, tvl_usd: 1000000 }],
|
|
35
|
+
});
|
|
36
|
+
} finally {
|
|
37
|
+
globalThis.fetch = previousFetch;
|
|
38
|
+
if (previousUrl === undefined) delete process.env.UPSTREAM_API_URL;
|
|
39
|
+
else process.env.UPSTREAM_API_URL = previousUrl;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("rejects an upstream host outside the manifest allowlist", async () => {
|
|
44
|
+
const previousUrl = process.env.UPSTREAM_API_URL;
|
|
45
|
+
process.env.UPSTREAM_API_URL = "https://attacker.example";
|
|
46
|
+
try {
|
|
47
|
+
await assert.rejects(
|
|
48
|
+
connector.invoke({
|
|
49
|
+
protocol_version: 1,
|
|
50
|
+
request_id: "template-request-2",
|
|
51
|
+
connector: { id: connector.manifest.id, version: connector.manifest.version },
|
|
52
|
+
tool: "get_pools",
|
|
53
|
+
arguments: { chain: "base" },
|
|
54
|
+
context: {},
|
|
55
|
+
}),
|
|
56
|
+
/permissions\.network_hosts/
|
|
57
|
+
);
|
|
58
|
+
} finally {
|
|
59
|
+
if (previousUrl === undefined) delete process.env.UPSTREAM_API_URL;
|
|
60
|
+
else process.env.UPSTREAM_API_URL = previousUrl;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2023",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noUncheckedIndexedAccess": true,
|
|
11
|
+
"exactOptionalPropertyTypes": true,
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"types": ["node"],
|
|
14
|
+
"skipLibCheck": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*.ts"]
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentlayer.tech/wallet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.103",
|
|
4
4
|
"description": "Universal AgentLayer wallet installer for OpenClaw, Codex, Claude Code, and Hermes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
".openclaw/extensions/agent-wallet/",
|
|
53
53
|
".claude-plugin/marketplace.json",
|
|
54
54
|
"codex/plugins/agent-wallet/",
|
|
55
|
+
"connectors/",
|
|
55
56
|
"claude-code/plugins/agent-wallet/",
|
|
56
57
|
"hermes/plugins/agent_wallet/",
|
|
57
58
|
"wdk-btc-wallet/src/",
|