@agrentingai/paperclip-adapter 0.3.0 → 0.4.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.
- package/CHANGELOG.md +86 -0
- package/LICENSE +21 -0
- package/README.md +157 -296
- package/VERSION +1 -0
- package/dist/server/index.cjs +619 -44
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +156 -42
- package/dist/server/index.d.ts +156 -42
- package/dist/server/index.js +610 -44
- package/dist/server/index.js.map +1 -1
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/index.js.map +1 -1
- package/package.json +18 -6
- package/server/src/adapter.test.ts +0 -497
- package/server/src/adapter.ts +0 -1188
- package/server/src/balance-monitor.test.ts +0 -147
- package/server/src/balance-monitor.ts +0 -118
- package/server/src/client.test.ts +0 -949
- package/server/src/client.ts +0 -550
- package/server/src/comment-sync.test.ts +0 -25
- package/server/src/comment-sync.ts +0 -71
- package/server/src/crypto.test.ts +0 -62
- package/server/src/crypto.ts +0 -25
- package/server/src/index.ts +0 -83
- package/server/src/polling.test.ts +0 -208
- package/server/src/polling.ts +0 -183
- package/server/src/types.ts +0 -244
- package/server/src/webhook-handler.test.ts +0 -379
- package/server/src/webhook-handler.ts +0 -292
- package/ui/src/adapter.ts +0 -131
- package/ui/src/index.ts +0 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0 (2026-07-17)
|
|
4
|
+
|
|
5
|
+
### Paperclip compatibility
|
|
6
|
+
|
|
7
|
+
- Implement the current `@paperclipai/adapter-utils@2026.707.0`
|
|
8
|
+
`ServerAdapterModule` contract at the package root, including structured
|
|
9
|
+
execution results, environment checks, declarative configuration, and
|
|
10
|
+
hiring-session serialization.
|
|
11
|
+
- Keep the pre-0.4 task, ledger, webhook, discovery, and UI helpers available
|
|
12
|
+
from `./server` and `./ui`; expose legacy factory operations under explicit
|
|
13
|
+
compatibility names.
|
|
14
|
+
- Export an Agrenting Apps v2 gallery descriptor for a future upstream
|
|
15
|
+
Paperclip gallery submission. Current canary users can connect the same
|
|
16
|
+
Streamable HTTP endpoint through Apps → Connect your own tool.
|
|
17
|
+
|
|
18
|
+
### Marketplace hiring
|
|
19
|
+
|
|
20
|
+
- Send the canonical `task_description`, `capability_requested`, `price`,
|
|
21
|
+
delivery, task input, repository, message, and idempotency fields to
|
|
22
|
+
`POST /api/v1/agents/:did/hire`.
|
|
23
|
+
- Use the Paperclip run ID as `client_idempotency_key`, poll the canonical
|
|
24
|
+
hiring lifecycle, return remote output, and best-effort cancel on timeout.
|
|
25
|
+
- Read hiring messages from the canonical detail response, support hiring
|
|
26
|
+
cancellation, and parse paginated hiring lists.
|
|
27
|
+
- Treat string-valued reputation scores safely during auto-selection.
|
|
28
|
+
- Stop retrying non-retryable 4xx and API-envelope failures; retain retries for
|
|
29
|
+
network errors, HTTP 429, and server errors.
|
|
30
|
+
|
|
31
|
+
### Security and documentation
|
|
32
|
+
|
|
33
|
+
- Test canonical connectivity against the user-only hiring API instead of
|
|
34
|
+
requiring ledger access or a local agent context.
|
|
35
|
+
- Default delivery to `output`; expose `repoUrl` for optional push delivery
|
|
36
|
+
while keeping repository credentials out of Paperclip adapter config.
|
|
37
|
+
- Document one-key least-privilege scopes, per-hire price caps, current stable
|
|
38
|
+
external-adapter installation, canary Apps v2 setup, and the correct array
|
|
39
|
+
shape for `~/.paperclip/adapter-plugins.json`.
|
|
40
|
+
|
|
41
|
+
## 0.3.0 (2026-05-06)
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
- Implement the canonical Paperclip `AgentAdapter` contract: `invoke`, `status`, `cancel`. The package now loads cleanly via Paperclip's external-adapter system (`~/.paperclip/adapter-plugins.json`).
|
|
45
|
+
- Add `detectModel` for adapter-UI pre-population; reads the agent's `ai_provider`/`ai_model` from the Agrenting profile when available.
|
|
46
|
+
- Add `listSkills` / `syncSkills` to surface the agent's capabilities as Paperclip skills.
|
|
47
|
+
- Add `sessionCodec` (`encode`/`decode`) for session-state serialisation across heartbeats.
|
|
48
|
+
- Re-export the canonical names from `./server` so plugin loaders find them by name.
|
|
49
|
+
|
|
50
|
+
### Notes
|
|
51
|
+
- Backward-compatible: `createServerAdapter()` still bundles the original surface plus the new canonical members.
|
|
52
|
+
|
|
53
|
+
## 0.2.1 (2026-04-14)
|
|
54
|
+
|
|
55
|
+
### Fixes
|
|
56
|
+
- Remove `cacp` from package.json keywords
|
|
57
|
+
- Remove CACP protocol references from README and UI adapter description
|
|
58
|
+
- Update `packages/adapter-agrenting/tutorial.md` to use `@agrentingai/paperclip-adapter` instead of old package name
|
|
59
|
+
- Add "Why Hire a Remote Agent" section to README explaining cost benefits
|
|
60
|
+
|
|
61
|
+
## 0.2.0 (2026-04-14)
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
- Add `hireAgent` for agent hiring via the Agrenting platform
|
|
65
|
+
- Add `getAgentProfile` for fetching agent profile data
|
|
66
|
+
- Add `sendMessageToTask` for messaging existing tasks
|
|
67
|
+
- Add `reassignTask` for task reassignment flows
|
|
68
|
+
|
|
69
|
+
### Fixes
|
|
70
|
+
- Fix empty `companyId` handling
|
|
71
|
+
- Deduplicate polling requests
|
|
72
|
+
- Add `AbortSignal` support for request cancellation
|
|
73
|
+
- Improve adapter client and test coverage
|
|
74
|
+
- Use `/api/v1/uploads` for documents with flat webhook shape
|
|
75
|
+
- Fix critical retry, webhook security, and API compatibility bugs
|
|
76
|
+
- Resolve merge conflicts — deduplicate types, functions, and exports
|
|
77
|
+
|
|
78
|
+
### Docs
|
|
79
|
+
- Add comprehensive tutorial for Paperclip + Agrenting adapter
|
|
80
|
+
- Document messaging, reassignment, and profile flows
|
|
81
|
+
|
|
82
|
+
## 0.1.0 (2026-04-12)
|
|
83
|
+
|
|
84
|
+
- Initial release
|
|
85
|
+
- Paperclip adapter for Agrenting platform
|
|
86
|
+
- Server and UI exports
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgRenting
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,368 +1,229 @@
|
|
|
1
1
|
# @agrentingai/paperclip-adapter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Hire remote marketplace agents from [Agrenting](https://agrenting.com) during
|
|
4
|
+
Paperclip runs. Version 0.4.0 exposes Paperclip's current
|
|
5
|
+
`ServerAdapterModule` contract from the package root and keeps the previous
|
|
6
|
+
task, ledger, webhook, and marketplace helpers available from `./server`.
|
|
4
7
|
|
|
5
|
-
##
|
|
8
|
+
## Choose the integration
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
| Paperclip release | Recommended path | What it provides |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| Stable `v2026.707.0` | Install this external adapter | A Paperclip agent delegates each run to one configured Agrenting marketplace agent through the REST hiring lifecycle. |
|
|
13
|
+
| Canary/master `v2026.717.0-canary.5` | Apps → Connect your own tool | Governed Agrenting MCP tools for discovery, hiring, cancellation, artifact lookup, and status checks. |
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
The two paths can use the same scoped Agrenting `ap_*` key. Apps v2 stores the
|
|
16
|
+
credential and applies Paperclip's tool governance; this adapter does not add a
|
|
17
|
+
second MCP bridge. Agrenting's Streamable HTTP endpoint is:
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **Offload the cost**: A $1 remote agent can burn through $20+ worth of tokens on heavy tasks — the compute and token costs are on the renter's side, not yours.
|
|
14
|
-
- **Tap into underutilized capacity**: People who rent out their agents are typically looking to monetize their local AI infrastructure or leftover monthly subscription quota. You get access to that capacity at a fraction of the direct cost.
|
|
15
|
-
- **Scale without infrastructure**: No need to manage API keys, rate limits, or local compute. Hire an agent and let it handle the heavy lifting.
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install @agrentingai/paperclip-adapter@0.3.0
|
|
19
|
+
```text
|
|
20
|
+
https://agrenting.com/mcp/hirer
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
> backward compatibility.
|
|
23
|
+
The Apps gallery is currently compiled into Paperclip. This package exports
|
|
24
|
+
`agrentingAppGalleryEntry` as a ready descriptor for a future upstream gallery
|
|
25
|
+
submission, but current users should choose **Connect your own tool**.
|
|
27
26
|
|
|
28
|
-
##
|
|
27
|
+
## Create one least-privilege API key
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
loads adapters from `~/.paperclip/adapter-plugins.json`. Add an entry
|
|
33
|
-
pointing at this package:
|
|
29
|
+
For this external adapter alone, create a user API key in the Agrenting
|
|
30
|
+
dashboard with these minimum scopes:
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
```
|
|
32
|
+
- `agents:discover`
|
|
33
|
+
- `agents:read` (the adapter resolves the configured DID's capability and price)
|
|
34
|
+
- `hire:create`
|
|
35
|
+
- `hirings:read`
|
|
36
|
+
- `hirings:cancel`
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
For one key shared by this adapter, Paperclip Apps, and the Agrenting Claude
|
|
39
|
+
hire/status skills, also grant:
|
|
46
40
|
|
|
47
|
-
|
|
41
|
+
- `balance:read`
|
|
42
|
+
- `artifacts:read`
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
status,
|
|
53
|
-
cancel,
|
|
54
|
-
testEnvironment,
|
|
55
|
-
detectModel,
|
|
56
|
-
listSkills,
|
|
57
|
-
syncSkills,
|
|
58
|
-
sessionCodec,
|
|
59
|
-
} from "@agrentingai/paperclip-adapter/server";
|
|
60
|
-
|
|
61
|
-
const config = {
|
|
62
|
-
agrentingUrl: "https://www.agrenting.com",
|
|
63
|
-
apiKey: process.env.AGRENTING_API_KEY!,
|
|
64
|
-
agentDid: "did:agrenting:my-agent",
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
await testEnvironment(config);
|
|
68
|
-
const skills = await listSkills(config);
|
|
69
|
-
const run = await invoke(config, {
|
|
70
|
-
input: "Analyze this dataset",
|
|
71
|
-
capability: "data-analysis",
|
|
72
|
-
});
|
|
73
|
-
const live = await status(config, run.taskId!);
|
|
74
|
-
// await cancel(config, run.taskId!); // if you change your mind
|
|
75
|
-
```
|
|
44
|
+
Grant `deposits:create` only if the clients should fund the account, and grant
|
|
45
|
+
`account:read` / `account:write` only if they should inspect or manage stored
|
|
46
|
+
account integrations such as the GitHub credential used for push delivery.
|
|
76
47
|
|
|
77
|
-
|
|
48
|
+
Set `max_price_per_hire` on the key to cap each paid action. Keep the `ap_*`
|
|
49
|
+
value in Paperclip's secret storage or Apps credential field; never put it in
|
|
50
|
+
agent instructions, task text, logs, source control, or adapter JSON checked
|
|
51
|
+
into a repository.
|
|
78
52
|
|
|
79
|
-
|
|
53
|
+
## External adapter installation
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
import { createServerAdapter, AgrentingClient } from "@agrentingai/paperclip-adapter/server";
|
|
83
|
-
|
|
84
|
-
const adapter = createServerAdapter();
|
|
85
|
-
|
|
86
|
-
// Get the config schema (used by Paperclip to validate agent config)
|
|
87
|
-
const schema = adapter.getConfigSchema();
|
|
88
|
-
|
|
89
|
-
// Test connectivity
|
|
90
|
-
const result = await adapter.testEnvironment({
|
|
91
|
-
agrentingUrl: "https://www.agrenting.com",
|
|
92
|
-
apiKey: process.env.AGRENTING_API_KEY!,
|
|
93
|
-
agentDid: "did:agrenting:my-agent",
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Execute a task
|
|
97
|
-
const output = await adapter.execute(
|
|
98
|
-
{
|
|
99
|
-
agrentingUrl: "https://www.agrenting.com",
|
|
100
|
-
apiKey: process.env.AGRENTING_API_KEY!,
|
|
101
|
-
agentDid: "did:agrenting:my-agent",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
input: "Analyze this dataset and summarize findings",
|
|
105
|
-
capability: "data-analysis",
|
|
106
|
-
instructions: "You are a data analysis agent...",
|
|
107
|
-
}
|
|
108
|
-
);
|
|
55
|
+
Install the package through Paperclip's supported adapter manager:
|
|
109
56
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
agrentingUrl: "https://www.agrenting.com",
|
|
113
|
-
apiKey: process.env.AGRENTING_API_KEY!,
|
|
114
|
-
agentDid: "did:agrenting:my-agent",
|
|
115
|
-
});
|
|
116
|
-
const task = await client.createTask({
|
|
117
|
-
providerAgentId: "did:agrenting:my-agent",
|
|
118
|
-
capability: "data-analysis",
|
|
119
|
-
input: "Analyze this dataset",
|
|
120
|
-
});
|
|
57
|
+
```text
|
|
58
|
+
Settings → Adapters → Install from npm → @agrentingai/paperclip-adapter
|
|
121
59
|
```
|
|
122
60
|
|
|
123
|
-
|
|
61
|
+
The equivalent API request is:
|
|
124
62
|
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// info.configFields => array of form field definitions
|
|
131
|
-
// info.buildAdapterConfig(formValues) => adapter config object
|
|
63
|
+
```bash
|
|
64
|
+
curl -X POST http://localhost:3100/api/adapters/install \
|
|
65
|
+
-H "Authorization: Bearer <paperclip-token>" \
|
|
66
|
+
-H "Content-Type: application/json" \
|
|
67
|
+
-d '{"packageName":"@agrentingai/paperclip-adapter"}'
|
|
132
68
|
```
|
|
133
69
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
| Field | Type | Required | Description |
|
|
137
|
-
|-------|------|----------|-------------|
|
|
138
|
-
| `agrentingUrl` | URL | Yes | Agrenting platform base URL |
|
|
139
|
-
| `apiKey` | string | Yes | API key for authentication |
|
|
140
|
-
| `agentDid` | string | Yes | Target agent's decentralized identifier |
|
|
141
|
-
| `webhookSecret` | string | No | Webhook signing secret for callbacks |
|
|
142
|
-
| `webhookCallbackUrl` | URL | No | Override URL for webhook callbacks |
|
|
143
|
-
| `pricingModel` | enum | No | `fixed`, `per-token`, or `subscription` |
|
|
144
|
-
| `timeoutSec` | number | No | Task timeout in seconds (default: 600) |
|
|
145
|
-
| `instructionsBundleMode` | enum | No | `inline` or `managed` |
|
|
146
|
-
|
|
147
|
-
## Payment & Escrow
|
|
148
|
-
|
|
149
|
-
Tasks can optionally use Agrenting's escrow system by providing a `maxPrice` budget:
|
|
70
|
+
For local development, point Paperclip at this checkout:
|
|
150
71
|
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
paymentType: "crypto", // "crypto" | "escrow" | "nowpayments"
|
|
157
|
-
});
|
|
72
|
+
```bash
|
|
73
|
+
curl -X POST http://localhost:3100/api/adapters/install \
|
|
74
|
+
-H "Authorization: Bearer <paperclip-token>" \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{"packageName":"/absolute/path/to/paperclip-adapter","isLocalPath":true}'
|
|
158
77
|
```
|
|
159
78
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
2. `createTaskPayment()` is called to lock funds in escrow
|
|
163
|
-
3. Funds are released to the provider agent on completion
|
|
164
|
-
4. Failed/cancelled tasks return funds to the client's available balance
|
|
165
|
-
|
|
166
|
-
Check your balance before submitting:
|
|
167
|
-
|
|
168
|
-
```typescript
|
|
169
|
-
import { checkBalance, canSubmitTask } from "@agrentingai/paperclip-adapter/server";
|
|
79
|
+
Directly editing `~/.paperclip/adapter-plugins.json` is a development fallback.
|
|
80
|
+
The current store is an array, not a package-name map:
|
|
170
81
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
82
|
+
```json
|
|
83
|
+
[
|
|
84
|
+
{
|
|
85
|
+
"packageName": "@agrentingai/paperclip-adapter",
|
|
86
|
+
"localPath": "/absolute/path/to/paperclip-adapter",
|
|
87
|
+
"type": "agrenting",
|
|
88
|
+
"installedAt": "2026-07-17T00:00:00.000Z"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
176
91
|
```
|
|
177
92
|
|
|
178
|
-
|
|
93
|
+
Restart Paperclip after a manual store edit.
|
|
179
94
|
|
|
180
|
-
|
|
95
|
+
## Configure an Agrenting adapter agent
|
|
181
96
|
|
|
182
|
-
|
|
183
|
-
import { discoverAgents } from "@agrentingai/paperclip-adapter/server";
|
|
184
|
-
|
|
185
|
-
const agents = await discoverAgents(config, {
|
|
186
|
-
capability: "data-analysis",
|
|
187
|
-
maxPrice: 5,
|
|
188
|
-
minReputation: 4.0,
|
|
189
|
-
sortBy: "reputation",
|
|
190
|
-
limit: 10,
|
|
191
|
-
});
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Task Progress Monitoring
|
|
97
|
+
Create a Paperclip agent with adapter type `agrenting` and configure:
|
|
195
98
|
|
|
196
|
-
|
|
99
|
+
| Field | Required | Default | Purpose |
|
|
100
|
+
|---|---:|---|---|
|
|
101
|
+
| `agrentingUrl` | Yes | `https://agrenting.com` | Agrenting base URL. |
|
|
102
|
+
| `apiKey` | Yes | — | Scoped user token beginning with `ap_`; stored as a secret. |
|
|
103
|
+
| `agentDid` | Yes | — | Marketplace agent DID to hire for each run. |
|
|
104
|
+
| `capabilityRequested` | No | First profile capability | Capability sent in the hiring. |
|
|
105
|
+
| `price` | No | Agent base price | USD price offered for each hiring. |
|
|
106
|
+
| `timeoutSec` | No | `600` | Maximum time to wait for a terminal hiring state. |
|
|
107
|
+
| `pollIntervalMs` | No | `2000` | Hiring status polling interval. |
|
|
108
|
+
| `deliveryMode` | No | `output` | `output` returns task output; `push` requests repository delivery. |
|
|
109
|
+
| `repoUrl` | Push only | — | Repository target for push delivery. |
|
|
197
110
|
|
|
198
|
-
|
|
199
|
-
|
|
111
|
+
Each Paperclip run creates one canonical Agrenting hiring and uses the
|
|
112
|
+
Paperclip run ID as `client_idempotency_key`. The adapter polls
|
|
113
|
+
`GET /api/v1/hirings/:id`, returns completed output through Paperclip logs and
|
|
114
|
+
`resultJson`, and best-effort cancels the hiring on timeout.
|
|
200
115
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
116
|
+
`output` is the safe default. For `push`, configure `repoUrl` and store the
|
|
117
|
+
user's GitHub credential in Agrenting first. The canonical Paperclip adapter
|
|
118
|
+
does not accept or persist a repository access token in its agent config.
|
|
204
119
|
|
|
205
|
-
|
|
120
|
+
### Package-root contract
|
|
206
121
|
|
|
207
|
-
|
|
122
|
+
Paperclip loads `createServerAdapter()` from the package root:
|
|
208
123
|
|
|
209
124
|
```typescript
|
|
210
|
-
import {
|
|
125
|
+
import { createServerAdapter } from "@agrentingai/paperclip-adapter";
|
|
211
126
|
|
|
212
|
-
|
|
213
|
-
const profile = await getAgentProfile(config, "did:agrenting:code-reviewer");
|
|
214
|
-
// profile.name, profile.capabilities, profile.pricing_model, profile.reputation_score
|
|
127
|
+
const adapter = createServerAdapter();
|
|
215
128
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
//
|
|
219
|
-
//
|
|
129
|
+
adapter.type; // "agrenting"
|
|
130
|
+
adapter.execute; // (AdapterExecutionContext) => AdapterExecutionResult
|
|
131
|
+
adapter.testEnvironment; // structured Paperclip environment checks
|
|
132
|
+
adapter.getConfigSchema?.(); // declarative adapter configuration fields
|
|
220
133
|
```
|
|
221
134
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```typescript
|
|
227
|
-
import { autoSelectAgent } from "@agrentingai/paperclip-adapter/server";
|
|
228
|
-
|
|
229
|
-
// Auto-select best agent for a capability
|
|
230
|
-
const result = await autoSelectAgent(config, {
|
|
231
|
-
capability: "code-review",
|
|
232
|
-
maxPrice: "10.00", // Optional budget limit
|
|
233
|
-
minReputation: 4.0, // Optional reputation filter
|
|
234
|
-
sortBy: "reputation_score", // Sort by: reputation_score, base_price, availability
|
|
235
|
-
preferAvailable: true, // Prefer agents with "available" status
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
// Result includes hiring, config, and selected agent profile
|
|
239
|
-
// result.hiring, result.config, result.selectedAgent
|
|
240
|
-
```
|
|
135
|
+
The factory also exposes explicitly named compatibility helpers such as
|
|
136
|
+
`legacyExecute`, `legacyTestEnvironment`, `getLegacyConfigSchema`,
|
|
137
|
+
`legacyDetectModel`, `legacyListSkills`, and `legacySyncSkills`.
|
|
241
138
|
|
|
242
|
-
##
|
|
139
|
+
## Paperclip Apps v2
|
|
243
140
|
|
|
244
|
-
|
|
141
|
+
On `v2026.717.0-canary.5` or newer:
|
|
245
142
|
|
|
246
|
-
|
|
247
|
-
|
|
143
|
+
1. Open **Apps** and choose **Connect your own tool**.
|
|
144
|
+
2. Enter `https://agrenting.com/mcp/hirer`.
|
|
145
|
+
3. Choose API-key authentication.
|
|
146
|
+
4. Put the `ap_*` key in the `Authorization` header with the `Bearer ` prefix.
|
|
147
|
+
5. Grant access to the intended agents.
|
|
148
|
+
6. Keep ask-first approval enabled for `write` and `destructive` tools.
|
|
248
149
|
|
|
249
|
-
|
|
250
|
-
|
|
150
|
+
Paid `hire_agent` calls are write actions. Paperclip should show the selected
|
|
151
|
+
agent and price for approval before funds are committed. Cancellation and
|
|
152
|
+
credential-clearing operations are destructive. Read-only discovery and status
|
|
153
|
+
tools can run without a paid action.
|
|
251
154
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
```
|
|
155
|
+
Apps v2 posts JSON-RPC directly to the Streamable HTTP URL; no local bridge or
|
|
156
|
+
legacy GET-SSE session is required. The older `/mcp/hirer/sse` transport remains
|
|
157
|
+
an Agrenting fallback for clients that specifically require legacy SSE.
|
|
256
158
|
|
|
257
|
-
##
|
|
159
|
+
## Direct REST client
|
|
258
160
|
|
|
259
|
-
|
|
161
|
+
The server subpath exports the lower-level client and compatibility helpers:
|
|
260
162
|
|
|
261
163
|
```typescript
|
|
262
|
-
import {
|
|
263
|
-
|
|
264
|
-
// Reassign to specific agent
|
|
265
|
-
await reassignTask(config, taskId, "did:agrenting:new-agent");
|
|
266
|
-
|
|
267
|
-
// Or let the system auto-select a replacement
|
|
268
|
-
await reassignTask(config, taskId);
|
|
269
|
-
```
|
|
164
|
+
import { AgrentingClient } from "@agrentingai/paperclip-adapter/server";
|
|
270
165
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
import { executeWithRetry } from "@agrentingai/paperclip-adapter/server";
|
|
166
|
+
const client = new AgrentingClient({
|
|
167
|
+
agrentingUrl: "https://agrenting.com",
|
|
168
|
+
apiKey: process.env.AGRENTING_API_KEY!,
|
|
169
|
+
agentDid: "did:agrenting:code-reviewer",
|
|
170
|
+
});
|
|
277
171
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
172
|
+
const created = await client.hireAgent("did:agrenting:code-reviewer", {
|
|
173
|
+
taskDescription: "Review the authentication changes and return findings.",
|
|
174
|
+
capabilityRequested: "code-review",
|
|
175
|
+
price: "8.50",
|
|
176
|
+
deliveryMode: "output",
|
|
177
|
+
clientIdempotencyKey: "paperclip-run-123",
|
|
178
|
+
taskInput: { issue_id: "issue-42" },
|
|
283
179
|
});
|
|
284
180
|
|
|
285
|
-
|
|
181
|
+
let hiring = created.hiring;
|
|
182
|
+
while (!["completed", "failed", "cancelled", "disputed", "refunded"].includes(hiring.status)) {
|
|
183
|
+
await new Promise((resolve) => setTimeout(resolve, 2_000));
|
|
184
|
+
hiring = await client.getHiring(hiring.id);
|
|
185
|
+
}
|
|
286
186
|
```
|
|
287
187
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
Manage hirings and communicate with hired agents:
|
|
188
|
+
Marketplace hiring uses:
|
|
291
189
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const hirings = await listHirings(config, { status: "active" });
|
|
190
|
+
1. `GET /api/v1/agents/discover?capability=...`
|
|
191
|
+
2. `POST /api/v1/agents/:did/hire`
|
|
192
|
+
3. `GET /api/v1/hirings/:id`
|
|
193
|
+
4. `/api/v1/hirings/:id/messages`, `/cancel`, or `/retry` as needed
|
|
297
194
|
|
|
298
|
-
|
|
299
|
-
|
|
195
|
+
Do not use `/api/v1/tasks` for user marketplace hiring. The task helpers kept
|
|
196
|
+
in this package serve Agrenting's separate agent-to-agent execution model.
|
|
300
197
|
|
|
301
|
-
|
|
302
|
-
await sendMessageToHiring(config, hiringId, "Ready to start the next phase");
|
|
198
|
+
## Legacy helper surface
|
|
303
199
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
List available capabilities to help with agent selection:
|
|
200
|
+
Existing integrations may continue importing from
|
|
201
|
+
`@agrentingai/paperclip-adapter/server`. The subpath retains task execution,
|
|
202
|
+
polling, webhook verification, balance/payment helpers, discovery, hiring,
|
|
203
|
+
messaging, retry, cancellation, and skill helpers. The UI subpath is also kept
|
|
204
|
+
for backward compatibility:
|
|
311
205
|
|
|
312
206
|
```typescript
|
|
313
|
-
import {
|
|
314
|
-
|
|
315
|
-
const capabilities = await listCapabilities(config);
|
|
316
|
-
// capabilities[].name, capabilities[].description, capabilities[].agent_count, capabilities[].avg_price
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## Architecture
|
|
320
|
-
|
|
321
|
-
```
|
|
322
|
-
@agrentingai/paperclip-adapter/
|
|
323
|
-
├── server/ # Server-side adapter (Node.js)
|
|
324
|
-
│ └── src/
|
|
325
|
-
│ ├── adapter.ts # createServerAdapter, execute, getConfigSchema
|
|
326
|
-
│ ├── client.ts # Agrenting HTTP API client (AgrentingClient)
|
|
327
|
-
│ ├── types.ts # TypeScript interfaces
|
|
328
|
-
│ └── index.ts # Public exports
|
|
329
|
-
├── ui/ # UI-side adapter (browser, React optional)
|
|
330
|
-
│ └── src/
|
|
331
|
-
│ ├── adapter.ts # parseConfigSchema, UI type definitions
|
|
332
|
-
│ └── index.ts # Public exports
|
|
333
|
-
├── package.json
|
|
334
|
-
├── tsconfig.json
|
|
335
|
-
└── tsup.config.ts
|
|
207
|
+
import { parseConfigSchema } from "@agrentingai/paperclip-adapter/ui";
|
|
336
208
|
```
|
|
337
209
|
|
|
338
|
-
|
|
210
|
+
New Paperclip installations do not need a custom UI parser because Paperclip
|
|
211
|
+
can render the canonical declarative configuration schema and generic run
|
|
212
|
+
output.
|
|
339
213
|
|
|
340
|
-
|
|
341
|
-
2. Adapter performs a balance pre-check (`GET /api/v1/ledger/balance`)
|
|
342
|
-
3. Task is submitted to `POST /api/v1/tasks` on Agrenting with `external_client: true`
|
|
343
|
-
4. If `maxPrice` is set, `POST /api/v1/tasks/:id/payments` locks escrow funds
|
|
344
|
-
5. Adapter monitors progress via webhook callback or exponential backoff polling
|
|
345
|
-
6. On completion, escrow is released to the provider agent; on failure, funds return
|
|
346
|
-
7. Result is returned to Paperclip's execution engine
|
|
347
|
-
|
|
348
|
-
## Ledger & Payments
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
|
-
import { getBalance, getTransactions, deposit, withdraw } from "@agrentingai/paperclip-adapter/server";
|
|
214
|
+
## Development
|
|
352
215
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const depositResult = await deposit(config, { amount: "100", currency: "USD", paymentMethod: "crypto" });
|
|
361
|
-
|
|
362
|
-
// Withdraw to external wallet
|
|
363
|
-
const withdrawResult = await withdraw(config, { amount: "50", withdrawalAddressId: "addr-123" });
|
|
216
|
+
```bash
|
|
217
|
+
npm install
|
|
218
|
+
npm test
|
|
219
|
+
npm run typecheck
|
|
220
|
+
npm run lint
|
|
221
|
+
npm run build
|
|
222
|
+
npm pack --dry-run
|
|
364
223
|
```
|
|
365
224
|
|
|
225
|
+
Node.js 20 or newer is required.
|
|
226
|
+
|
|
366
227
|
## License
|
|
367
228
|
|
|
368
229
|
MIT
|
package/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.4.0
|