@t54-labs/clawcredit-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.
Files changed (2) hide show
  1. package/README.md +114 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # ClawCredit SDK for Open Claw
2
+
3
+ ClawCredit provides a credit line and payment workflow for Open Claw Agents using t54's Trustline and the x402 protocol.
4
+ This SDK lets an agent register for credit, submit audit materials, and pay
5
+ merchants with this credit service. Trustline's risk engine evaluates the
6
+ agent's integration depth, richness of risk signals, and credit history
7
+ (including on-time repayments and other records) to issue updated credit
8
+ limits daily or dynamically.
9
+
10
+ ## About Open Claw
11
+
12
+ Open Claw is an open-source agent framework that runs your personal AI assistant
13
+ across platforms, with a gateway, skills, and channel integrations. It is
14
+ designed to let agents run locally or remotely, with a configurable workspace
15
+ and a modular “skills” system you can extend.
16
+ Repository: https://github.com/openclaw/openclaw
17
+
18
+ ## Quick Start
19
+
20
+ Install the SDK:
21
+
22
+ ```bash
23
+ npm install @t54-labs/clawcredit-sdk
24
+ ```
25
+
26
+ Initialize and register:
27
+
28
+ ```javascript
29
+ const { ClawCredit, audit } = require('@t54-labs/clawcredit-sdk');
30
+
31
+ function myCoreLogic(input) {
32
+ return input * 2;
33
+ }
34
+
35
+ // Optional but recommended: capture core code for audit
36
+ audit(myCoreLogic);
37
+
38
+ const credit = new ClawCredit({
39
+ agentName: "MyOpenClawAgent"
40
+ });
41
+
42
+ await credit.register({
43
+ inviteCode: "YOUR_INVITE_CODE",
44
+ coreCode: "function main() { ... }",
45
+ systemPrompt: "You are a helpful assistant.",
46
+ runtimeEnv: "node-v22",
47
+ model: "gpt-5.2" // Optional
48
+ });
49
+ ```
50
+
51
+ ## Enable Reasoning Trace (Recommended)
52
+
53
+ Trace helps the risk engine evaluate why a payment is needed.
54
+
55
+ ```javascript
56
+ const OpenAI = require('openai');
57
+ const { wrapOpenAI, withTrace } = require('@t54-labs/clawcredit-sdk');
58
+
59
+ const openai = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));
60
+
61
+ await withTrace(async () => {
62
+ await openai.chat.completions.create({
63
+ messages: [{ role: "user", content: "Fetch the latest BTC price." }],
64
+ model: "gpt-5.2"
65
+ });
66
+ });
67
+ ```
68
+
69
+ ## Pay a Merchant
70
+
71
+ ```javascript
72
+ const result = await credit.pay({
73
+ transaction: {
74
+ recipient: "merchant_address_or_id",
75
+ amount: 1.5,
76
+ chain: "BASE",
77
+ asset: "USDC"
78
+ },
79
+ request_body: {
80
+ service_name: "PremiumSearch",
81
+ params: { query: "BTC price" }
82
+ },
83
+ // Optional: reasoning process can increase approval probability
84
+ // context: { reasoning_process: "I need real-time data to answer the user." }
85
+ });
86
+
87
+ console.log(result);
88
+ ```
89
+
90
+ ## How an Open Claw Agent Learns This Skill
91
+
92
+ Open Claw agents can be taught via a skill guide. Provide the agent with the
93
+ `SKILL.md` in this package and instruct it to:
94
+
95
+ 1. Install the SDK: `npm install @t54-labs/clawcredit-sdk`
96
+ 2. Register using `credit.register()` with audit materials.
97
+ 3. Wrap the OpenAI client with `wrapOpenAI()` for trace capture.
98
+ 4. Use `credit.pay()` with `transaction` and `request_body`.
99
+
100
+ The `SKILL.md` file in this package contains a step-by-step guide tailored for
101
+ agent use. You can host it and prompt agents to read and follow it.
102
+
103
+ ## Exports
104
+
105
+ ```javascript
106
+ const {
107
+ ClawCredit,
108
+ audit,
109
+ wrapOpenAI,
110
+ withTrace
111
+ } = require('@t54-labs/clawcredit-sdk');
112
+ ```
113
+
114
+
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@t54-labs/clawcredit-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Integration SDK for Open Claw Agents to access ClawCredit",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "axios": "^1.6.0",
8
8
  "uuid": "^9.0.0"
9
- }
9
+ },
10
+ "license": "MIT"
10
11
  }
11
-