@atlasauth/pca-anthropic 0.1.0 → 0.3.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/LICENSE +21 -0
- package/README.md +45 -22
- package/package.json +26 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Atlas Authorization
|
|
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,39 +1,62 @@
|
|
|
1
1
|
# @atlasauth/pca-anthropic
|
|
2
2
|
|
|
3
|
-
Anthropic (Claude) adapter for Proof-Carrying Authority
|
|
3
|
+
Anthropic (Claude) adapter for Proof-Carrying Authority (PCA). It sits between a Claude `tool_use` block and the `tool_result` you send back: it turns the block into a PCActn (a signed proof-carrying action) using a PCA `Agent`, runs your handler with the proof in hand, and returns the `tool_result` block, including the error-shaped result Claude expects when a tool is declined or throws.
|
|
4
|
+
|
|
5
|
+
It does not authorize anything itself: it attaches a proof, and the resource server's verifier decides. A handler that forgets to forward the proof just produces a downstream call without a valid PCActn, which fails server-side.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
npm i @atlasauth/pca-anthropic
|
|
9
|
-
# peer dependency, install alongside:
|
|
10
|
+
npm i @atlasauth/pca-anthropic @atlasauth/pca
|
|
10
11
|
npm i @anthropic-ai/sdk
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
`@anthropic-ai/sdk` is an optional peer dependency.
|
|
14
|
+
`@anthropic-ai/sdk` is an optional peer dependency; the adapter models only the block shapes it touches and does not import the SDK at runtime.
|
|
14
15
|
|
|
15
16
|
## Usage
|
|
16
17
|
|
|
17
18
|
```ts
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
import { agent, generateKeyPair } from '@atlasauth/pca';
|
|
20
|
+
import { handleToolUses, extractToolUses } from '@atlasauth/pca-anthropic';
|
|
21
|
+
|
|
22
|
+
const pcaAgent = agent({
|
|
23
|
+
principal: generateKeyPair(),
|
|
24
|
+
goal: 'issue refunds',
|
|
25
|
+
permissions: { stripe: ['refund'] },
|
|
26
|
+
limits: { refund: '$500/day' },
|
|
27
|
+
aud: 'ins_acme', // the id your resource server verifies against
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// After each assistant turn, answer every tool_use block:
|
|
31
|
+
const toolResults = await handleToolUses(
|
|
32
|
+
pcaAgent,
|
|
33
|
+
extractToolUses(message.content),
|
|
34
|
+
({ name, input }) => // map tool -> { verb, resource }; return null to decline
|
|
35
|
+
name === 'refund' ? { verb: 'stripe.refund', resource: `charge:${input.chargeId}` } : null,
|
|
36
|
+
{
|
|
37
|
+
refund: async (input, pca) => { // pca.headers / pca.encoded carry the signed proof
|
|
38
|
+
return doRefund(input, pca.headers);
|
|
31
39
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
// -> [{ type: 'tool_result', tool_use_id, content }]; is_error: true when declined, unhandled or thrown
|
|
43
|
+
// Append them to your next user message's content.
|
|
35
44
|
```
|
|
36
45
|
|
|
37
|
-
`handleToolUse`
|
|
46
|
+
`handleToolUse` does the same for a single block. On success `content` is the JSON of your handler's return value (or `{ pca: <encoded> }` if it returns nothing).
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
- `handleToolUse(agent, block, map, handlers, opts?)`, `handleToolUses(agent, blocks, map, handlers, opts?)`, `extractToolUses(content)`.
|
|
51
|
+
- Types: `ToolUseBlock`, `ToolResultBlock`, `ToolMapping`, `ToolHandler`.
|
|
52
|
+
- Re-exports from `@atlasauth/pca`: `pcaHeaders`, `PcaCall`.
|
|
53
|
+
|
|
54
|
+
## Status
|
|
55
|
+
|
|
56
|
+
Experimental. The underlying cryptography in `@atlasauth/pca` has not been independently audited.
|
|
57
|
+
|
|
58
|
+
Source and issues: https://github.com/Atlas-Authorization/pca
|
|
59
|
+
|
|
60
|
+
## License
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
MIT - see LICENSE
|
package/package.json
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/pca-anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Anthropic (Claude) adapter for Proof-Carrying Authority: turn a tool_use block into a PCActn and build the tool_result with the proof attached.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"anthropic",
|
|
7
|
+
"claude",
|
|
8
|
+
"tool use",
|
|
9
|
+
"agent authorization",
|
|
10
|
+
"proof-carrying authority",
|
|
11
|
+
"pca",
|
|
12
|
+
"ai agents"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/Atlas-Authorization/pca#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Atlas-Authorization/pca/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Atlas-Authorization/pca.git",
|
|
22
|
+
"directory": "packages/pca-anthropic"
|
|
23
|
+
},
|
|
5
24
|
"main": "./dist/index.js",
|
|
6
25
|
"types": "./dist/index.d.ts",
|
|
7
26
|
"exports": {
|
|
@@ -12,7 +31,7 @@
|
|
|
12
31
|
"./package.json": "./package.json"
|
|
13
32
|
},
|
|
14
33
|
"dependencies": {
|
|
15
|
-
"@atlasauth/pca": "0.
|
|
34
|
+
"@atlasauth/pca": "0.3.0"
|
|
16
35
|
},
|
|
17
36
|
"peerDependencies": {
|
|
18
37
|
"@anthropic-ai/sdk": "^0.30 || ^0.40 || ^0.50"
|
|
@@ -28,8 +47,12 @@
|
|
|
28
47
|
},
|
|
29
48
|
"files": [
|
|
30
49
|
"dist",
|
|
31
|
-
"README.md"
|
|
50
|
+
"README.md",
|
|
51
|
+
"LICENSE"
|
|
32
52
|
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20"
|
|
55
|
+
},
|
|
33
56
|
"publishConfig": {
|
|
34
57
|
"access": "public"
|
|
35
58
|
},
|