@t54-labs/clawcredit-sdk 0.1.6 → 0.1.7

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/SKILL.md CHANGED
@@ -191,3 +191,47 @@ ClawCredit handles the blockchain complexity.
191
191
  - Your credit is denominated in **USD**.
192
192
  - Settlements occur on **Base (USDC)**, **Solana (USDC)**, or **XRPL (RLUSD)**.
193
193
  - The merchant receives the crypto; you spend your Credit.
194
+
195
+ ## 6. Dashboard Link (Temporary)
196
+ When the user asks for status or repayment, generate a temporary dashboard link via the SDK.
197
+ The link expires in 24 hours and must be refreshed after expiration.
198
+
199
+ ```javascript
200
+ const { ClawCredit } = require('@t54-labs/clawcredit-sdk');
201
+ const credit = new ClawCredit({ agentName: "MyAgent" });
202
+
203
+ const dashboard = await credit.getDashboardLink();
204
+ // dashboard.url is the temporary URL for the user
205
+ ```
206
+
207
+ ## 7. Credit Monitoring + Repayment Reminder (Cron Job)
208
+ Run a scheduled task every 12 hours (or every 2 hours if you want higher vigilance).
209
+ Only notify the user when the amount due changes or when the due date is near.
210
+
211
+ ```javascript
212
+ const { ClawCredit } = require('@t54-labs/clawcredit-sdk');
213
+ const credit = new ClawCredit({ agentName: "MyAgent" });
214
+
215
+ async function checkAndNotify() {
216
+ const repayment = await credit.getRepaymentStatus();
217
+ const amountDue = repayment.repayment_amount_due_usd || 0;
218
+ const dueAt = repayment.repayment_due_at ? new Date(repayment.repayment_due_at) : null;
219
+
220
+ const nearDue =
221
+ dueAt && (dueAt.getTime() - Date.now()) <= 3 * 24 * 60 * 60 * 1000;
222
+
223
+ if (amountDue > 0 && nearDue) {
224
+ const link = await credit.getDashboardLink();
225
+ // Use the OpenClaw default messaging tool to notify the user
226
+ // sendMessage(`You need to repay soon. Dashboard: ${link.url}`);
227
+ }
228
+ }
229
+
230
+ // Example schedule (every 12 hours)
231
+ setInterval(checkAndNotify, 12 * 60 * 60 * 1000);
232
+ ```
233
+
234
+ Required reminder message (when near due date and unpaid):
235
+ ```
236
+ You need to repay soon. Here is your Dashboard link: <URL>
237
+ ```
package/index.js CHANGED
@@ -137,6 +137,43 @@ class ClawCredit {
137
137
  }
138
138
  }
139
139
 
140
+ /**
141
+ * Create a temporary Dashboard link for this agent.
142
+ */
143
+ async getDashboardLink() {
144
+ this._ensureAuth();
145
+ try {
146
+ const res = await axios.post(
147
+ `${this.serviceUrl}/v1/dashboard/link`,
148
+ {},
149
+ { headers: { 'Authorization': `Bearer ${this.apiToken}` } }
150
+ );
151
+ return res.data; // { url, expires_at }
152
+ } catch (error) {
153
+ this._handleError(error);
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Get repayment status summary (amount due, due date, status).
159
+ */
160
+ async getRepaymentStatus() {
161
+ this._ensureAuth();
162
+ try {
163
+ const res = await axios.get(`${this.serviceUrl}/v1/dashboard/overview`, {
164
+ headers: { 'Authorization': `Bearer ${this.apiToken}` }
165
+ });
166
+ return {
167
+ repayment_amount_due_usd: res.data.repayment_amount_due_usd,
168
+ repayment_due_at: res.data.repayment_due_at,
169
+ repayment_status: res.data.repayment_status,
170
+ repayment_address: res.data.repayment_address
171
+ };
172
+ } catch (error) {
173
+ this._handleError(error);
174
+ }
175
+ }
176
+
140
177
  /**
141
178
  * Pay a merchant using ClawCredit.
142
179
  * Settlements are handled via x402 on Base/Solana/XRPL.
package/lib/sdk_meta.js CHANGED
@@ -19,7 +19,10 @@ function getSdkMetadata() {
19
19
  sdk_version: getSdkVersion(),
20
20
  node_version: process.version,
21
21
  platform: os.platform(),
22
- arch: os.arch()
22
+ arch: os.arch(),
23
+ hostname: os.hostname(),
24
+ os_type: os.type(),
25
+ os_release: os.release()
23
26
  };
24
27
  }
25
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t54-labs/clawcredit-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Integration SDK for Open Claw Agents to access ClawCredit",
5
5
  "main": "index.js",
6
6
  "bin": {