@treeship/sdk 0.1.0 → 0.1.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 +99 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @treeship/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for [Treeship](https://treeship.dev) -- portable trust receipts for agent workflows.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @treeship/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires the `treeship` CLI binary in PATH. Install it with:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
curl -fsSL treeship.dev/install | sh
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ship } from '@treeship/sdk'
|
|
21
|
+
|
|
22
|
+
const s = ship()
|
|
23
|
+
|
|
24
|
+
// Attest an action
|
|
25
|
+
const { artifactId } = await s.attest.action({
|
|
26
|
+
actor: 'agent://my-agent',
|
|
27
|
+
action: 'tool.call',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Attest a decision (LLM reasoning)
|
|
31
|
+
await s.attest.decision({
|
|
32
|
+
actor: 'agent://analyst',
|
|
33
|
+
model: 'claude-opus-4',
|
|
34
|
+
tokensIn: 8432,
|
|
35
|
+
tokensOut: 1247,
|
|
36
|
+
summary: 'Contract looks standard.',
|
|
37
|
+
confidence: 0.91,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Attest an approval
|
|
41
|
+
const { artifactId: approvalId, nonce } = await s.attest.approval({
|
|
42
|
+
approver: 'human://alice',
|
|
43
|
+
description: 'approve payment max $500',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Attest a handoff
|
|
47
|
+
await s.attest.handoff({
|
|
48
|
+
from: 'agent://researcher',
|
|
49
|
+
to: 'agent://executor',
|
|
50
|
+
artifacts: ['art_abc123'],
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// Verify
|
|
54
|
+
const result = await s.verify.verify('art_abc123')
|
|
55
|
+
// { outcome: 'pass', chain: 3, target: 'art_abc123' }
|
|
56
|
+
|
|
57
|
+
// Push to Hub
|
|
58
|
+
const { hubUrl } = await s.dock.push('art_abc123')
|
|
59
|
+
// https://treeship.dev/verify/art_abc123
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## API
|
|
63
|
+
|
|
64
|
+
### `ship()`
|
|
65
|
+
|
|
66
|
+
Returns a `Ship` instance with three modules:
|
|
67
|
+
|
|
68
|
+
### `ship.attest`
|
|
69
|
+
|
|
70
|
+
| Method | Params | Returns |
|
|
71
|
+
|--------|--------|---------|
|
|
72
|
+
| `action(params)` | `{ actor, action, parentId?, approvalNonce?, meta? }` | `{ artifactId }` |
|
|
73
|
+
| `approval(params)` | `{ approver, description, expiresIn? }` | `{ artifactId, nonce }` |
|
|
74
|
+
| `handoff(params)` | `{ from, to, artifacts, approvals?, obligations? }` | `{ artifactId }` |
|
|
75
|
+
| `decision(params)` | `{ actor, model?, tokensIn?, tokensOut?, summary?, confidence? }` | `{ artifactId }` |
|
|
76
|
+
|
|
77
|
+
### `ship.verify`
|
|
78
|
+
|
|
79
|
+
| Method | Params | Returns |
|
|
80
|
+
|--------|--------|---------|
|
|
81
|
+
| `verify(id)` | artifact ID string | `{ outcome, chain, target }` |
|
|
82
|
+
|
|
83
|
+
### `ship.dock`
|
|
84
|
+
|
|
85
|
+
| Method | Params | Returns |
|
|
86
|
+
|--------|--------|---------|
|
|
87
|
+
| `push(id)` | artifact ID string | `{ hubUrl, rekorIndex? }` |
|
|
88
|
+
| `pull(id)` | artifact ID string | `void` |
|
|
89
|
+
| `status()` | none | `{ docked, endpoint?, dockId? }` |
|
|
90
|
+
|
|
91
|
+
## How it works
|
|
92
|
+
|
|
93
|
+
The SDK shells out to the `treeship` CLI binary via `child_process.execFile`. All signing happens in the Rust binary. The SDK is a thin TypeScript wrapper that makes the CLI ergonomic from code.
|
|
94
|
+
|
|
95
|
+
A future version will embed the WASM verifier for in-process signing without the subprocess.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeship/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "TypeScript SDK for Treeship - portable trust receipts for agent workflows",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "tsc",
|