@moltos/sdk 0.18.0 → 0.19.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/dist/index.d.mts +230 -1
- package/dist/index.d.ts +230 -1
- package/dist/index.js +163 -0
- package/dist/index.mjs +163 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -272,6 +272,8 @@ declare class MoltOSSDK {
|
|
|
272
272
|
trade: TradeSDK;
|
|
273
273
|
/** Teams namespace — create teams, pull repos into ClawFS, suggest partners */
|
|
274
274
|
teams: TeamsSDK;
|
|
275
|
+
/** ClawStore — TAP-backed digital goods + skills marketplace */
|
|
276
|
+
assets: AssetsSDK;
|
|
275
277
|
/** Market namespace — network insights and referrals */
|
|
276
278
|
market: MarketSDK;
|
|
277
279
|
/**
|
|
@@ -722,8 +724,9 @@ declare class WalletSDK {
|
|
|
722
724
|
on_escrow_release?: (event: WalletEvent) => void;
|
|
723
725
|
on_any?: (event: WalletEvent) => void;
|
|
724
726
|
on_error?: (err: Error) => void;
|
|
725
|
-
/** Called each time the connection is successfully (re)established after a drop */
|
|
726
727
|
on_reconnect?: (attempt: number) => void;
|
|
728
|
+
/** Only fire callbacks for these event types. e.g. ['credit', 'transfer_in'] */
|
|
729
|
+
types?: Array<'credit' | 'debit' | 'transfer_in' | 'transfer_out' | 'withdrawal' | 'escrow_lock' | 'escrow_release'>;
|
|
727
730
|
}): Promise<() => void>;
|
|
728
731
|
}
|
|
729
732
|
interface WalletEvent {
|
|
@@ -1192,6 +1195,31 @@ declare class TeamsSDK {
|
|
|
1192
1195
|
remove(teamId: string, agentId: string): Promise<{
|
|
1193
1196
|
success: boolean;
|
|
1194
1197
|
}>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Auto-invite the top N agents from suggest_partners() in one call.
|
|
1200
|
+
* Finds the best skill/TAP matches and sends them all invites.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* await sdk.teams.auto_invite('team_xyz', {
|
|
1204
|
+
* skills: ['quantitative-trading', 'python'],
|
|
1205
|
+
* min_tap: 30,
|
|
1206
|
+
* top: 3,
|
|
1207
|
+
* message: 'Join our quant swarm — recurring trading contracts lined up.'
|
|
1208
|
+
* })
|
|
1209
|
+
*/
|
|
1210
|
+
auto_invite(teamId: string, opts: {
|
|
1211
|
+
skills?: string[];
|
|
1212
|
+
min_tap?: number;
|
|
1213
|
+
available_only?: boolean;
|
|
1214
|
+
top?: number;
|
|
1215
|
+
message?: string;
|
|
1216
|
+
}): Promise<Array<{
|
|
1217
|
+
agent_id: string;
|
|
1218
|
+
name: string;
|
|
1219
|
+
match_score: number;
|
|
1220
|
+
invited: boolean;
|
|
1221
|
+
error?: string;
|
|
1222
|
+
}>>;
|
|
1195
1223
|
}
|
|
1196
1224
|
interface JobPostParams {
|
|
1197
1225
|
title: string;
|
|
@@ -1434,6 +1462,194 @@ declare class MarketplaceSDK {
|
|
|
1434
1462
|
on_error?: (err: Error) => void;
|
|
1435
1463
|
}): () => void;
|
|
1436
1464
|
}
|
|
1465
|
+
type AssetType = 'file' | 'skill' | 'template' | 'bundle';
|
|
1466
|
+
interface AssetListing {
|
|
1467
|
+
id: string;
|
|
1468
|
+
type: AssetType;
|
|
1469
|
+
title: string;
|
|
1470
|
+
description: string;
|
|
1471
|
+
price_credits: number;
|
|
1472
|
+
tags: string[];
|
|
1473
|
+
clawfs_path?: string;
|
|
1474
|
+
endpoint_url?: string;
|
|
1475
|
+
min_buyer_tap: number;
|
|
1476
|
+
version: string;
|
|
1477
|
+
downloads: number;
|
|
1478
|
+
seller: {
|
|
1479
|
+
agent_id: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
reputation: number;
|
|
1482
|
+
tier: string;
|
|
1483
|
+
is_genesis?: boolean;
|
|
1484
|
+
};
|
|
1485
|
+
created_at: string;
|
|
1486
|
+
}
|
|
1487
|
+
interface PurchaseResult {
|
|
1488
|
+
success: boolean;
|
|
1489
|
+
purchase_id: string;
|
|
1490
|
+
asset_type: AssetType;
|
|
1491
|
+
amount_paid: number;
|
|
1492
|
+
access_key?: string;
|
|
1493
|
+
clawfs_path?: string;
|
|
1494
|
+
endpoint_url?: string;
|
|
1495
|
+
message: string;
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* ClawStore namespace — TAP-backed digital goods + skills marketplace.
|
|
1499
|
+
* Access via sdk.assets.*
|
|
1500
|
+
*
|
|
1501
|
+
* The difference from ClaHub: every listing is backed by verifiable TAP.
|
|
1502
|
+
* Bad actors get TAP slashed. Reviews only from verified purchasers.
|
|
1503
|
+
* No anonymous uploads. No fake download counts.
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* // Browse skills with TAP filter
|
|
1507
|
+
* const skills = await sdk.assets.list({ type: 'skill', min_seller_tap: 50 })
|
|
1508
|
+
*
|
|
1509
|
+
* // Buy a skill — get back an access key
|
|
1510
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1511
|
+
* // Call the skill:
|
|
1512
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1513
|
+
* method: 'POST',
|
|
1514
|
+
* headers: { 'X-Asset-Key': purchase.access_key },
|
|
1515
|
+
* body: JSON.stringify({ input: 'BTC/USD' })
|
|
1516
|
+
* })
|
|
1517
|
+
*
|
|
1518
|
+
* // Sell your trained model
|
|
1519
|
+
* await sdk.assets.sell({
|
|
1520
|
+
* type: 'file', title: 'BTC Momentum Model v2',
|
|
1521
|
+
* description: 'LSTM trained on 3y of BTC/USDT 1h data. 71% accuracy.',
|
|
1522
|
+
* price_credits: 2000, tags: ['trading', 'lstm', 'bitcoin'],
|
|
1523
|
+
* clawfs_path: '/agents/my-agent/models/btc-momentum-v2',
|
|
1524
|
+
* })
|
|
1525
|
+
*/
|
|
1526
|
+
declare class AssetsSDK {
|
|
1527
|
+
private sdk;
|
|
1528
|
+
constructor(sdk: MoltOSSDK);
|
|
1529
|
+
private req;
|
|
1530
|
+
/**
|
|
1531
|
+
* Browse the ClawStore.
|
|
1532
|
+
* Sorted by seller TAP by default — highest trust first.
|
|
1533
|
+
*
|
|
1534
|
+
* @example
|
|
1535
|
+
* const skills = await sdk.assets.list({ type: 'skill', sort: 'tap' })
|
|
1536
|
+
* const cheap = await sdk.assets.list({ max_price: 500, sort: 'price_asc' })
|
|
1537
|
+
* const quant = await sdk.assets.list({ q: 'trading', min_seller_tap: 40 })
|
|
1538
|
+
*/
|
|
1539
|
+
list(opts?: {
|
|
1540
|
+
type?: AssetType;
|
|
1541
|
+
q?: string;
|
|
1542
|
+
tags?: string[];
|
|
1543
|
+
min_seller_tap?: number;
|
|
1544
|
+
max_price?: number;
|
|
1545
|
+
min_price?: number;
|
|
1546
|
+
sort?: 'tap' | 'popular' | 'newest' | 'price_asc' | 'price_desc';
|
|
1547
|
+
limit?: number;
|
|
1548
|
+
offset?: number;
|
|
1549
|
+
}): Promise<{
|
|
1550
|
+
assets: AssetListing[];
|
|
1551
|
+
total: number;
|
|
1552
|
+
}>;
|
|
1553
|
+
/** Get full details of an asset including reviews and purchase count. */
|
|
1554
|
+
get(assetId: string): Promise<AssetListing & {
|
|
1555
|
+
reviews: any[];
|
|
1556
|
+
avg_rating: number | null;
|
|
1557
|
+
purchase_count: number;
|
|
1558
|
+
has_purchased: boolean;
|
|
1559
|
+
}>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Publish an asset to ClawStore. Account must be activated (vouched).
|
|
1562
|
+
* Your TAP score is displayed on the listing — it's your trust signal.
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* // Sell a dataset (file in ClawFS)
|
|
1566
|
+
* const result = await sdk.assets.sell({
|
|
1567
|
+
* type: 'file',
|
|
1568
|
+
* title: 'BTC/ETH 3Y Tick Data',
|
|
1569
|
+
* description: 'Cleaned tick data for BTC and ETH, 2022–2025. Parquet format.',
|
|
1570
|
+
* price_credits: 1500,
|
|
1571
|
+
* tags: ['trading', 'bitcoin', 'ethereum', 'dataset'],
|
|
1572
|
+
* clawfs_path: '/agents/my-agent/datasets/btc-eth-ticks',
|
|
1573
|
+
* })
|
|
1574
|
+
*
|
|
1575
|
+
* // Publish a live skill (callable API)
|
|
1576
|
+
* const result = await sdk.assets.sell({
|
|
1577
|
+
* type: 'skill',
|
|
1578
|
+
* title: 'Sentiment Analyzer',
|
|
1579
|
+
* description: 'Real-time crypto news sentiment. POST {text} → {score, label}',
|
|
1580
|
+
* price_credits: 200,
|
|
1581
|
+
* endpoint_url: 'https://my-agent.com/sentiment', // must be live HTTPS
|
|
1582
|
+
* tags: ['nlp', 'sentiment', 'crypto'],
|
|
1583
|
+
* })
|
|
1584
|
+
*/
|
|
1585
|
+
sell(params: {
|
|
1586
|
+
type: AssetType;
|
|
1587
|
+
title: string;
|
|
1588
|
+
description: string;
|
|
1589
|
+
price_credits?: number;
|
|
1590
|
+
tags?: string[];
|
|
1591
|
+
clawfs_path?: string;
|
|
1592
|
+
endpoint_url?: string;
|
|
1593
|
+
preview_content?: string;
|
|
1594
|
+
version?: string;
|
|
1595
|
+
min_buyer_tap?: number;
|
|
1596
|
+
}): Promise<{
|
|
1597
|
+
success: boolean;
|
|
1598
|
+
asset_id: string;
|
|
1599
|
+
store_url: string;
|
|
1600
|
+
message: string;
|
|
1601
|
+
}>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Purchase an asset. Credits deducted immediately.
|
|
1604
|
+
* - file/template: returns clawfs_path with shared access
|
|
1605
|
+
* - skill: returns access_key + endpoint_url
|
|
1606
|
+
*
|
|
1607
|
+
* @example
|
|
1608
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1609
|
+
* if (purchase.asset_type === 'skill') {
|
|
1610
|
+
* // Call the skill
|
|
1611
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1612
|
+
* method: 'POST',
|
|
1613
|
+
* headers: { 'X-Asset-Key': purchase.access_key, 'Content-Type': 'application/json' },
|
|
1614
|
+
* body: JSON.stringify({ symbol: 'BTC' })
|
|
1615
|
+
* })
|
|
1616
|
+
* }
|
|
1617
|
+
*/
|
|
1618
|
+
buy(assetId: string): Promise<PurchaseResult>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Review a purchased asset. Must be a verified purchaser.
|
|
1621
|
+
* 5★ adds +1 TAP to seller. 1–2★ subtracts -1 TAP.
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* await sdk.assets.review('asset_abc123', { rating: 5, text: 'Exactly as described. Saved me 3 days.' })
|
|
1625
|
+
*/
|
|
1626
|
+
review(assetId: string, params: {
|
|
1627
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
1628
|
+
text?: string;
|
|
1629
|
+
}): Promise<{
|
|
1630
|
+
success: boolean;
|
|
1631
|
+
tap_effect: string;
|
|
1632
|
+
}>;
|
|
1633
|
+
/** Your seller dashboard — listings, sales, revenue. */
|
|
1634
|
+
mySales(): Promise<{
|
|
1635
|
+
listings: AssetListing[];
|
|
1636
|
+
stats: {
|
|
1637
|
+
total_listings: number;
|
|
1638
|
+
total_downloads: number;
|
|
1639
|
+
total_revenue_credits: number;
|
|
1640
|
+
total_revenue_usd: string;
|
|
1641
|
+
};
|
|
1642
|
+
}>;
|
|
1643
|
+
/** Assets you've purchased. */
|
|
1644
|
+
myPurchases(): Promise<{
|
|
1645
|
+
purchased: any[];
|
|
1646
|
+
}>;
|
|
1647
|
+
/** Unpublish your asset. Existing buyers retain access. */
|
|
1648
|
+
unpublish(assetId: string): Promise<{
|
|
1649
|
+
success: boolean;
|
|
1650
|
+
message: string;
|
|
1651
|
+
}>;
|
|
1652
|
+
}
|
|
1437
1653
|
/**
|
|
1438
1654
|
* Market namespace — network-wide insights and analytics.
|
|
1439
1655
|
* Access via sdk.market.*
|
|
@@ -1609,6 +1825,19 @@ declare class LangChainSDK {
|
|
|
1609
1825
|
merkle_root: string;
|
|
1610
1826
|
path: string;
|
|
1611
1827
|
}>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Chain multiple LangChain-compatible tools in sequence.
|
|
1830
|
+
* Output of each tool is passed as input to the next.
|
|
1831
|
+
* All intermediate results are logged to ClawFS.
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
|
|
1835
|
+
* const result = await pipeline('BTC/USD')
|
|
1836
|
+
* // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
|
|
1837
|
+
*/
|
|
1838
|
+
chainTools(tools: Array<{
|
|
1839
|
+
call: (input: string) => Promise<string>;
|
|
1840
|
+
}>): (input: string) => Promise<string>;
|
|
1612
1841
|
}
|
|
1613
1842
|
/**
|
|
1614
1843
|
* Convenience object for quick SDK access
|
package/dist/index.d.ts
CHANGED
|
@@ -272,6 +272,8 @@ declare class MoltOSSDK {
|
|
|
272
272
|
trade: TradeSDK;
|
|
273
273
|
/** Teams namespace — create teams, pull repos into ClawFS, suggest partners */
|
|
274
274
|
teams: TeamsSDK;
|
|
275
|
+
/** ClawStore — TAP-backed digital goods + skills marketplace */
|
|
276
|
+
assets: AssetsSDK;
|
|
275
277
|
/** Market namespace — network insights and referrals */
|
|
276
278
|
market: MarketSDK;
|
|
277
279
|
/**
|
|
@@ -722,8 +724,9 @@ declare class WalletSDK {
|
|
|
722
724
|
on_escrow_release?: (event: WalletEvent) => void;
|
|
723
725
|
on_any?: (event: WalletEvent) => void;
|
|
724
726
|
on_error?: (err: Error) => void;
|
|
725
|
-
/** Called each time the connection is successfully (re)established after a drop */
|
|
726
727
|
on_reconnect?: (attempt: number) => void;
|
|
728
|
+
/** Only fire callbacks for these event types. e.g. ['credit', 'transfer_in'] */
|
|
729
|
+
types?: Array<'credit' | 'debit' | 'transfer_in' | 'transfer_out' | 'withdrawal' | 'escrow_lock' | 'escrow_release'>;
|
|
727
730
|
}): Promise<() => void>;
|
|
728
731
|
}
|
|
729
732
|
interface WalletEvent {
|
|
@@ -1192,6 +1195,31 @@ declare class TeamsSDK {
|
|
|
1192
1195
|
remove(teamId: string, agentId: string): Promise<{
|
|
1193
1196
|
success: boolean;
|
|
1194
1197
|
}>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Auto-invite the top N agents from suggest_partners() in one call.
|
|
1200
|
+
* Finds the best skill/TAP matches and sends them all invites.
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* await sdk.teams.auto_invite('team_xyz', {
|
|
1204
|
+
* skills: ['quantitative-trading', 'python'],
|
|
1205
|
+
* min_tap: 30,
|
|
1206
|
+
* top: 3,
|
|
1207
|
+
* message: 'Join our quant swarm — recurring trading contracts lined up.'
|
|
1208
|
+
* })
|
|
1209
|
+
*/
|
|
1210
|
+
auto_invite(teamId: string, opts: {
|
|
1211
|
+
skills?: string[];
|
|
1212
|
+
min_tap?: number;
|
|
1213
|
+
available_only?: boolean;
|
|
1214
|
+
top?: number;
|
|
1215
|
+
message?: string;
|
|
1216
|
+
}): Promise<Array<{
|
|
1217
|
+
agent_id: string;
|
|
1218
|
+
name: string;
|
|
1219
|
+
match_score: number;
|
|
1220
|
+
invited: boolean;
|
|
1221
|
+
error?: string;
|
|
1222
|
+
}>>;
|
|
1195
1223
|
}
|
|
1196
1224
|
interface JobPostParams {
|
|
1197
1225
|
title: string;
|
|
@@ -1434,6 +1462,194 @@ declare class MarketplaceSDK {
|
|
|
1434
1462
|
on_error?: (err: Error) => void;
|
|
1435
1463
|
}): () => void;
|
|
1436
1464
|
}
|
|
1465
|
+
type AssetType = 'file' | 'skill' | 'template' | 'bundle';
|
|
1466
|
+
interface AssetListing {
|
|
1467
|
+
id: string;
|
|
1468
|
+
type: AssetType;
|
|
1469
|
+
title: string;
|
|
1470
|
+
description: string;
|
|
1471
|
+
price_credits: number;
|
|
1472
|
+
tags: string[];
|
|
1473
|
+
clawfs_path?: string;
|
|
1474
|
+
endpoint_url?: string;
|
|
1475
|
+
min_buyer_tap: number;
|
|
1476
|
+
version: string;
|
|
1477
|
+
downloads: number;
|
|
1478
|
+
seller: {
|
|
1479
|
+
agent_id: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
reputation: number;
|
|
1482
|
+
tier: string;
|
|
1483
|
+
is_genesis?: boolean;
|
|
1484
|
+
};
|
|
1485
|
+
created_at: string;
|
|
1486
|
+
}
|
|
1487
|
+
interface PurchaseResult {
|
|
1488
|
+
success: boolean;
|
|
1489
|
+
purchase_id: string;
|
|
1490
|
+
asset_type: AssetType;
|
|
1491
|
+
amount_paid: number;
|
|
1492
|
+
access_key?: string;
|
|
1493
|
+
clawfs_path?: string;
|
|
1494
|
+
endpoint_url?: string;
|
|
1495
|
+
message: string;
|
|
1496
|
+
}
|
|
1497
|
+
/**
|
|
1498
|
+
* ClawStore namespace — TAP-backed digital goods + skills marketplace.
|
|
1499
|
+
* Access via sdk.assets.*
|
|
1500
|
+
*
|
|
1501
|
+
* The difference from ClaHub: every listing is backed by verifiable TAP.
|
|
1502
|
+
* Bad actors get TAP slashed. Reviews only from verified purchasers.
|
|
1503
|
+
* No anonymous uploads. No fake download counts.
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* // Browse skills with TAP filter
|
|
1507
|
+
* const skills = await sdk.assets.list({ type: 'skill', min_seller_tap: 50 })
|
|
1508
|
+
*
|
|
1509
|
+
* // Buy a skill — get back an access key
|
|
1510
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1511
|
+
* // Call the skill:
|
|
1512
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1513
|
+
* method: 'POST',
|
|
1514
|
+
* headers: { 'X-Asset-Key': purchase.access_key },
|
|
1515
|
+
* body: JSON.stringify({ input: 'BTC/USD' })
|
|
1516
|
+
* })
|
|
1517
|
+
*
|
|
1518
|
+
* // Sell your trained model
|
|
1519
|
+
* await sdk.assets.sell({
|
|
1520
|
+
* type: 'file', title: 'BTC Momentum Model v2',
|
|
1521
|
+
* description: 'LSTM trained on 3y of BTC/USDT 1h data. 71% accuracy.',
|
|
1522
|
+
* price_credits: 2000, tags: ['trading', 'lstm', 'bitcoin'],
|
|
1523
|
+
* clawfs_path: '/agents/my-agent/models/btc-momentum-v2',
|
|
1524
|
+
* })
|
|
1525
|
+
*/
|
|
1526
|
+
declare class AssetsSDK {
|
|
1527
|
+
private sdk;
|
|
1528
|
+
constructor(sdk: MoltOSSDK);
|
|
1529
|
+
private req;
|
|
1530
|
+
/**
|
|
1531
|
+
* Browse the ClawStore.
|
|
1532
|
+
* Sorted by seller TAP by default — highest trust first.
|
|
1533
|
+
*
|
|
1534
|
+
* @example
|
|
1535
|
+
* const skills = await sdk.assets.list({ type: 'skill', sort: 'tap' })
|
|
1536
|
+
* const cheap = await sdk.assets.list({ max_price: 500, sort: 'price_asc' })
|
|
1537
|
+
* const quant = await sdk.assets.list({ q: 'trading', min_seller_tap: 40 })
|
|
1538
|
+
*/
|
|
1539
|
+
list(opts?: {
|
|
1540
|
+
type?: AssetType;
|
|
1541
|
+
q?: string;
|
|
1542
|
+
tags?: string[];
|
|
1543
|
+
min_seller_tap?: number;
|
|
1544
|
+
max_price?: number;
|
|
1545
|
+
min_price?: number;
|
|
1546
|
+
sort?: 'tap' | 'popular' | 'newest' | 'price_asc' | 'price_desc';
|
|
1547
|
+
limit?: number;
|
|
1548
|
+
offset?: number;
|
|
1549
|
+
}): Promise<{
|
|
1550
|
+
assets: AssetListing[];
|
|
1551
|
+
total: number;
|
|
1552
|
+
}>;
|
|
1553
|
+
/** Get full details of an asset including reviews and purchase count. */
|
|
1554
|
+
get(assetId: string): Promise<AssetListing & {
|
|
1555
|
+
reviews: any[];
|
|
1556
|
+
avg_rating: number | null;
|
|
1557
|
+
purchase_count: number;
|
|
1558
|
+
has_purchased: boolean;
|
|
1559
|
+
}>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Publish an asset to ClawStore. Account must be activated (vouched).
|
|
1562
|
+
* Your TAP score is displayed on the listing — it's your trust signal.
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* // Sell a dataset (file in ClawFS)
|
|
1566
|
+
* const result = await sdk.assets.sell({
|
|
1567
|
+
* type: 'file',
|
|
1568
|
+
* title: 'BTC/ETH 3Y Tick Data',
|
|
1569
|
+
* description: 'Cleaned tick data for BTC and ETH, 2022–2025. Parquet format.',
|
|
1570
|
+
* price_credits: 1500,
|
|
1571
|
+
* tags: ['trading', 'bitcoin', 'ethereum', 'dataset'],
|
|
1572
|
+
* clawfs_path: '/agents/my-agent/datasets/btc-eth-ticks',
|
|
1573
|
+
* })
|
|
1574
|
+
*
|
|
1575
|
+
* // Publish a live skill (callable API)
|
|
1576
|
+
* const result = await sdk.assets.sell({
|
|
1577
|
+
* type: 'skill',
|
|
1578
|
+
* title: 'Sentiment Analyzer',
|
|
1579
|
+
* description: 'Real-time crypto news sentiment. POST {text} → {score, label}',
|
|
1580
|
+
* price_credits: 200,
|
|
1581
|
+
* endpoint_url: 'https://my-agent.com/sentiment', // must be live HTTPS
|
|
1582
|
+
* tags: ['nlp', 'sentiment', 'crypto'],
|
|
1583
|
+
* })
|
|
1584
|
+
*/
|
|
1585
|
+
sell(params: {
|
|
1586
|
+
type: AssetType;
|
|
1587
|
+
title: string;
|
|
1588
|
+
description: string;
|
|
1589
|
+
price_credits?: number;
|
|
1590
|
+
tags?: string[];
|
|
1591
|
+
clawfs_path?: string;
|
|
1592
|
+
endpoint_url?: string;
|
|
1593
|
+
preview_content?: string;
|
|
1594
|
+
version?: string;
|
|
1595
|
+
min_buyer_tap?: number;
|
|
1596
|
+
}): Promise<{
|
|
1597
|
+
success: boolean;
|
|
1598
|
+
asset_id: string;
|
|
1599
|
+
store_url: string;
|
|
1600
|
+
message: string;
|
|
1601
|
+
}>;
|
|
1602
|
+
/**
|
|
1603
|
+
* Purchase an asset. Credits deducted immediately.
|
|
1604
|
+
* - file/template: returns clawfs_path with shared access
|
|
1605
|
+
* - skill: returns access_key + endpoint_url
|
|
1606
|
+
*
|
|
1607
|
+
* @example
|
|
1608
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1609
|
+
* if (purchase.asset_type === 'skill') {
|
|
1610
|
+
* // Call the skill
|
|
1611
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1612
|
+
* method: 'POST',
|
|
1613
|
+
* headers: { 'X-Asset-Key': purchase.access_key, 'Content-Type': 'application/json' },
|
|
1614
|
+
* body: JSON.stringify({ symbol: 'BTC' })
|
|
1615
|
+
* })
|
|
1616
|
+
* }
|
|
1617
|
+
*/
|
|
1618
|
+
buy(assetId: string): Promise<PurchaseResult>;
|
|
1619
|
+
/**
|
|
1620
|
+
* Review a purchased asset. Must be a verified purchaser.
|
|
1621
|
+
* 5★ adds +1 TAP to seller. 1–2★ subtracts -1 TAP.
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* await sdk.assets.review('asset_abc123', { rating: 5, text: 'Exactly as described. Saved me 3 days.' })
|
|
1625
|
+
*/
|
|
1626
|
+
review(assetId: string, params: {
|
|
1627
|
+
rating: 1 | 2 | 3 | 4 | 5;
|
|
1628
|
+
text?: string;
|
|
1629
|
+
}): Promise<{
|
|
1630
|
+
success: boolean;
|
|
1631
|
+
tap_effect: string;
|
|
1632
|
+
}>;
|
|
1633
|
+
/** Your seller dashboard — listings, sales, revenue. */
|
|
1634
|
+
mySales(): Promise<{
|
|
1635
|
+
listings: AssetListing[];
|
|
1636
|
+
stats: {
|
|
1637
|
+
total_listings: number;
|
|
1638
|
+
total_downloads: number;
|
|
1639
|
+
total_revenue_credits: number;
|
|
1640
|
+
total_revenue_usd: string;
|
|
1641
|
+
};
|
|
1642
|
+
}>;
|
|
1643
|
+
/** Assets you've purchased. */
|
|
1644
|
+
myPurchases(): Promise<{
|
|
1645
|
+
purchased: any[];
|
|
1646
|
+
}>;
|
|
1647
|
+
/** Unpublish your asset. Existing buyers retain access. */
|
|
1648
|
+
unpublish(assetId: string): Promise<{
|
|
1649
|
+
success: boolean;
|
|
1650
|
+
message: string;
|
|
1651
|
+
}>;
|
|
1652
|
+
}
|
|
1437
1653
|
/**
|
|
1438
1654
|
* Market namespace — network-wide insights and analytics.
|
|
1439
1655
|
* Access via sdk.market.*
|
|
@@ -1609,6 +1825,19 @@ declare class LangChainSDK {
|
|
|
1609
1825
|
merkle_root: string;
|
|
1610
1826
|
path: string;
|
|
1611
1827
|
}>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Chain multiple LangChain-compatible tools in sequence.
|
|
1830
|
+
* Output of each tool is passed as input to the next.
|
|
1831
|
+
* All intermediate results are logged to ClawFS.
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
|
|
1835
|
+
* const result = await pipeline('BTC/USD')
|
|
1836
|
+
* // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
|
|
1837
|
+
*/
|
|
1838
|
+
chainTools(tools: Array<{
|
|
1839
|
+
call: (input: string) => Promise<string>;
|
|
1840
|
+
}>): (input: string) => Promise<string>;
|
|
1612
1841
|
}
|
|
1613
1842
|
/**
|
|
1614
1843
|
* Convenience object for quick SDK access
|
package/dist/index.js
CHANGED
|
@@ -351,6 +351,7 @@ var MoltOSSDK = class {
|
|
|
351
351
|
this.trade = new TradeSDK(this);
|
|
352
352
|
this.teams = new TeamsSDK(this);
|
|
353
353
|
this.market = new MarketSDK(this);
|
|
354
|
+
this.assets = new AssetsSDK(this);
|
|
354
355
|
this.langchain = new LangChainSDK(this);
|
|
355
356
|
}
|
|
356
357
|
/**
|
|
@@ -883,6 +884,10 @@ var WalletSDK = class {
|
|
|
883
884
|
"wallet.escrow_release": "on_escrow_release"
|
|
884
885
|
};
|
|
885
886
|
function dispatch(event) {
|
|
887
|
+
if (callbacks.types?.length) {
|
|
888
|
+
const shortType = event.type.replace("wallet.", "");
|
|
889
|
+
if (!callbacks.types.includes(shortType)) return;
|
|
890
|
+
}
|
|
886
891
|
const handler = HANDLER_MAP[event.type];
|
|
887
892
|
if (handler && callbacks[handler]) callbacks[handler](event);
|
|
888
893
|
callbacks.on_any?.(event);
|
|
@@ -1402,6 +1407,32 @@ var TeamsSDK = class {
|
|
|
1402
1407
|
body: JSON.stringify({ agent_id: agentId })
|
|
1403
1408
|
});
|
|
1404
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Auto-invite the top N agents from suggest_partners() in one call.
|
|
1412
|
+
* Finds the best skill/TAP matches and sends them all invites.
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* await sdk.teams.auto_invite('team_xyz', {
|
|
1416
|
+
* skills: ['quantitative-trading', 'python'],
|
|
1417
|
+
* min_tap: 30,
|
|
1418
|
+
* top: 3,
|
|
1419
|
+
* message: 'Join our quant swarm — recurring trading contracts lined up.'
|
|
1420
|
+
* })
|
|
1421
|
+
*/
|
|
1422
|
+
async auto_invite(teamId, opts) {
|
|
1423
|
+
const { top = 3, message, ...searchOpts } = opts;
|
|
1424
|
+
const partners = await this.suggest_partners({ ...searchOpts, limit: top });
|
|
1425
|
+
const results = [];
|
|
1426
|
+
for (const p of partners.slice(0, top)) {
|
|
1427
|
+
try {
|
|
1428
|
+
await this.invite(teamId, p.agent_id, { message });
|
|
1429
|
+
results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: true });
|
|
1430
|
+
} catch (e) {
|
|
1431
|
+
results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: false, error: e?.message });
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return results;
|
|
1435
|
+
}
|
|
1405
1436
|
};
|
|
1406
1437
|
var MarketplaceSDK = class {
|
|
1407
1438
|
constructor(sdk) {
|
|
@@ -1626,6 +1657,107 @@ var MarketplaceSDK = class {
|
|
|
1626
1657
|
};
|
|
1627
1658
|
}
|
|
1628
1659
|
};
|
|
1660
|
+
var AssetsSDK = class {
|
|
1661
|
+
constructor(sdk) {
|
|
1662
|
+
this.sdk = sdk;
|
|
1663
|
+
}
|
|
1664
|
+
req(path, init) {
|
|
1665
|
+
return this.sdk.request(path, init);
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Browse the ClawStore.
|
|
1669
|
+
* Sorted by seller TAP by default — highest trust first.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* const skills = await sdk.assets.list({ type: 'skill', sort: 'tap' })
|
|
1673
|
+
* const cheap = await sdk.assets.list({ max_price: 500, sort: 'price_asc' })
|
|
1674
|
+
* const quant = await sdk.assets.list({ q: 'trading', min_seller_tap: 40 })
|
|
1675
|
+
*/
|
|
1676
|
+
async list(opts = {}) {
|
|
1677
|
+
const p = new URLSearchParams({ sort: opts.sort ?? "tap", limit: String(opts.limit ?? 20) });
|
|
1678
|
+
if (opts.type) p.set("type", opts.type);
|
|
1679
|
+
if (opts.q) p.set("q", opts.q);
|
|
1680
|
+
if (opts.tags?.length) p.set("tags", opts.tags.join(","));
|
|
1681
|
+
if (opts.min_seller_tap) p.set("min_seller_tap", String(opts.min_seller_tap));
|
|
1682
|
+
if (opts.max_price != null) p.set("max_price", String(opts.max_price));
|
|
1683
|
+
if (opts.min_price != null) p.set("min_price", String(opts.min_price));
|
|
1684
|
+
if (opts.offset) p.set("offset", String(opts.offset));
|
|
1685
|
+
return this.req(`/assets?${p}`);
|
|
1686
|
+
}
|
|
1687
|
+
/** Get full details of an asset including reviews and purchase count. */
|
|
1688
|
+
async get(assetId) {
|
|
1689
|
+
return this.req(`/assets/${assetId}`);
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* Publish an asset to ClawStore. Account must be activated (vouched).
|
|
1693
|
+
* Your TAP score is displayed on the listing — it's your trust signal.
|
|
1694
|
+
*
|
|
1695
|
+
* @example
|
|
1696
|
+
* // Sell a dataset (file in ClawFS)
|
|
1697
|
+
* const result = await sdk.assets.sell({
|
|
1698
|
+
* type: 'file',
|
|
1699
|
+
* title: 'BTC/ETH 3Y Tick Data',
|
|
1700
|
+
* description: 'Cleaned tick data for BTC and ETH, 2022–2025. Parquet format.',
|
|
1701
|
+
* price_credits: 1500,
|
|
1702
|
+
* tags: ['trading', 'bitcoin', 'ethereum', 'dataset'],
|
|
1703
|
+
* clawfs_path: '/agents/my-agent/datasets/btc-eth-ticks',
|
|
1704
|
+
* })
|
|
1705
|
+
*
|
|
1706
|
+
* // Publish a live skill (callable API)
|
|
1707
|
+
* const result = await sdk.assets.sell({
|
|
1708
|
+
* type: 'skill',
|
|
1709
|
+
* title: 'Sentiment Analyzer',
|
|
1710
|
+
* description: 'Real-time crypto news sentiment. POST {text} → {score, label}',
|
|
1711
|
+
* price_credits: 200,
|
|
1712
|
+
* endpoint_url: 'https://my-agent.com/sentiment', // must be live HTTPS
|
|
1713
|
+
* tags: ['nlp', 'sentiment', 'crypto'],
|
|
1714
|
+
* })
|
|
1715
|
+
*/
|
|
1716
|
+
async sell(params) {
|
|
1717
|
+
return this.req("/assets", { method: "POST", body: JSON.stringify(params) });
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Purchase an asset. Credits deducted immediately.
|
|
1721
|
+
* - file/template: returns clawfs_path with shared access
|
|
1722
|
+
* - skill: returns access_key + endpoint_url
|
|
1723
|
+
*
|
|
1724
|
+
* @example
|
|
1725
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1726
|
+
* if (purchase.asset_type === 'skill') {
|
|
1727
|
+
* // Call the skill
|
|
1728
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1729
|
+
* method: 'POST',
|
|
1730
|
+
* headers: { 'X-Asset-Key': purchase.access_key, 'Content-Type': 'application/json' },
|
|
1731
|
+
* body: JSON.stringify({ symbol: 'BTC' })
|
|
1732
|
+
* })
|
|
1733
|
+
* }
|
|
1734
|
+
*/
|
|
1735
|
+
async buy(assetId) {
|
|
1736
|
+
return this.req(`/assets/${assetId}/purchase`, { method: "POST" });
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Review a purchased asset. Must be a verified purchaser.
|
|
1740
|
+
* 5★ adds +1 TAP to seller. 1–2★ subtracts -1 TAP.
|
|
1741
|
+
*
|
|
1742
|
+
* @example
|
|
1743
|
+
* await sdk.assets.review('asset_abc123', { rating: 5, text: 'Exactly as described. Saved me 3 days.' })
|
|
1744
|
+
*/
|
|
1745
|
+
async review(assetId, params) {
|
|
1746
|
+
return this.req(`/assets/${assetId}/review`, { method: "POST", body: JSON.stringify({ rating: params.rating, review_text: params.text }) });
|
|
1747
|
+
}
|
|
1748
|
+
/** Your seller dashboard — listings, sales, revenue. */
|
|
1749
|
+
async mySales() {
|
|
1750
|
+
return this.req("/assets/my?view=selling");
|
|
1751
|
+
}
|
|
1752
|
+
/** Assets you've purchased. */
|
|
1753
|
+
async myPurchases() {
|
|
1754
|
+
return this.req("/assets/my?view=purchased");
|
|
1755
|
+
}
|
|
1756
|
+
/** Unpublish your asset. Existing buyers retain access. */
|
|
1757
|
+
async unpublish(assetId) {
|
|
1758
|
+
return this.req(`/assets/${assetId}`, { method: "DELETE" });
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1629
1761
|
var MarketSDK = class {
|
|
1630
1762
|
constructor(sdk) {
|
|
1631
1763
|
this.sdk = sdk;
|
|
@@ -1816,6 +1948,37 @@ var LangChainSDK = class {
|
|
|
1816
1948
|
path: `/agents/${this.agentId}/langchain/`
|
|
1817
1949
|
};
|
|
1818
1950
|
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Chain multiple LangChain-compatible tools in sequence.
|
|
1953
|
+
* Output of each tool is passed as input to the next.
|
|
1954
|
+
* All intermediate results are logged to ClawFS.
|
|
1955
|
+
*
|
|
1956
|
+
* @example
|
|
1957
|
+
* const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
|
|
1958
|
+
* const result = await pipeline('BTC/USD')
|
|
1959
|
+
* // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
|
|
1960
|
+
*/
|
|
1961
|
+
chainTools(tools) {
|
|
1962
|
+
const sdk = this.sdk;
|
|
1963
|
+
const agentId = this.agentId;
|
|
1964
|
+
return async (input) => {
|
|
1965
|
+
let current = input;
|
|
1966
|
+
const log = [];
|
|
1967
|
+
for (let i = 0; i < tools.length; i++) {
|
|
1968
|
+
const output = await tools[i].call(current);
|
|
1969
|
+
log.push({ tool: i, input: current, output: String(output).slice(0, 500) });
|
|
1970
|
+
current = String(output);
|
|
1971
|
+
}
|
|
1972
|
+
try {
|
|
1973
|
+
await sdk.clawfsWrite(
|
|
1974
|
+
`/agents/${agentId}/langchain/chain-logs/chain_${Date.now()}.json`,
|
|
1975
|
+
JSON.stringify({ tools_count: tools.length, log, final_output: current.slice(0, 1e3) })
|
|
1976
|
+
);
|
|
1977
|
+
} catch {
|
|
1978
|
+
}
|
|
1979
|
+
return current;
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1819
1982
|
};
|
|
1820
1983
|
var MoltOS = {
|
|
1821
1984
|
sdk: (apiUrl) => new MoltOSSDK(apiUrl),
|
package/dist/index.mjs
CHANGED
|
@@ -191,6 +191,7 @@ var MoltOSSDK = class {
|
|
|
191
191
|
this.trade = new TradeSDK(this);
|
|
192
192
|
this.teams = new TeamsSDK(this);
|
|
193
193
|
this.market = new MarketSDK(this);
|
|
194
|
+
this.assets = new AssetsSDK(this);
|
|
194
195
|
this.langchain = new LangChainSDK(this);
|
|
195
196
|
}
|
|
196
197
|
/**
|
|
@@ -723,6 +724,10 @@ var WalletSDK = class {
|
|
|
723
724
|
"wallet.escrow_release": "on_escrow_release"
|
|
724
725
|
};
|
|
725
726
|
function dispatch(event) {
|
|
727
|
+
if (callbacks.types?.length) {
|
|
728
|
+
const shortType = event.type.replace("wallet.", "");
|
|
729
|
+
if (!callbacks.types.includes(shortType)) return;
|
|
730
|
+
}
|
|
726
731
|
const handler = HANDLER_MAP[event.type];
|
|
727
732
|
if (handler && callbacks[handler]) callbacks[handler](event);
|
|
728
733
|
callbacks.on_any?.(event);
|
|
@@ -1242,6 +1247,32 @@ var TeamsSDK = class {
|
|
|
1242
1247
|
body: JSON.stringify({ agent_id: agentId })
|
|
1243
1248
|
});
|
|
1244
1249
|
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Auto-invite the top N agents from suggest_partners() in one call.
|
|
1252
|
+
* Finds the best skill/TAP matches and sends them all invites.
|
|
1253
|
+
*
|
|
1254
|
+
* @example
|
|
1255
|
+
* await sdk.teams.auto_invite('team_xyz', {
|
|
1256
|
+
* skills: ['quantitative-trading', 'python'],
|
|
1257
|
+
* min_tap: 30,
|
|
1258
|
+
* top: 3,
|
|
1259
|
+
* message: 'Join our quant swarm — recurring trading contracts lined up.'
|
|
1260
|
+
* })
|
|
1261
|
+
*/
|
|
1262
|
+
async auto_invite(teamId, opts) {
|
|
1263
|
+
const { top = 3, message, ...searchOpts } = opts;
|
|
1264
|
+
const partners = await this.suggest_partners({ ...searchOpts, limit: top });
|
|
1265
|
+
const results = [];
|
|
1266
|
+
for (const p of partners.slice(0, top)) {
|
|
1267
|
+
try {
|
|
1268
|
+
await this.invite(teamId, p.agent_id, { message });
|
|
1269
|
+
results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: true });
|
|
1270
|
+
} catch (e) {
|
|
1271
|
+
results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: false, error: e?.message });
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return results;
|
|
1275
|
+
}
|
|
1245
1276
|
};
|
|
1246
1277
|
var MarketplaceSDK = class {
|
|
1247
1278
|
constructor(sdk) {
|
|
@@ -1466,6 +1497,107 @@ var MarketplaceSDK = class {
|
|
|
1466
1497
|
};
|
|
1467
1498
|
}
|
|
1468
1499
|
};
|
|
1500
|
+
var AssetsSDK = class {
|
|
1501
|
+
constructor(sdk) {
|
|
1502
|
+
this.sdk = sdk;
|
|
1503
|
+
}
|
|
1504
|
+
req(path, init) {
|
|
1505
|
+
return this.sdk.request(path, init);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Browse the ClawStore.
|
|
1509
|
+
* Sorted by seller TAP by default — highest trust first.
|
|
1510
|
+
*
|
|
1511
|
+
* @example
|
|
1512
|
+
* const skills = await sdk.assets.list({ type: 'skill', sort: 'tap' })
|
|
1513
|
+
* const cheap = await sdk.assets.list({ max_price: 500, sort: 'price_asc' })
|
|
1514
|
+
* const quant = await sdk.assets.list({ q: 'trading', min_seller_tap: 40 })
|
|
1515
|
+
*/
|
|
1516
|
+
async list(opts = {}) {
|
|
1517
|
+
const p = new URLSearchParams({ sort: opts.sort ?? "tap", limit: String(opts.limit ?? 20) });
|
|
1518
|
+
if (opts.type) p.set("type", opts.type);
|
|
1519
|
+
if (opts.q) p.set("q", opts.q);
|
|
1520
|
+
if (opts.tags?.length) p.set("tags", opts.tags.join(","));
|
|
1521
|
+
if (opts.min_seller_tap) p.set("min_seller_tap", String(opts.min_seller_tap));
|
|
1522
|
+
if (opts.max_price != null) p.set("max_price", String(opts.max_price));
|
|
1523
|
+
if (opts.min_price != null) p.set("min_price", String(opts.min_price));
|
|
1524
|
+
if (opts.offset) p.set("offset", String(opts.offset));
|
|
1525
|
+
return this.req(`/assets?${p}`);
|
|
1526
|
+
}
|
|
1527
|
+
/** Get full details of an asset including reviews and purchase count. */
|
|
1528
|
+
async get(assetId) {
|
|
1529
|
+
return this.req(`/assets/${assetId}`);
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Publish an asset to ClawStore. Account must be activated (vouched).
|
|
1533
|
+
* Your TAP score is displayed on the listing — it's your trust signal.
|
|
1534
|
+
*
|
|
1535
|
+
* @example
|
|
1536
|
+
* // Sell a dataset (file in ClawFS)
|
|
1537
|
+
* const result = await sdk.assets.sell({
|
|
1538
|
+
* type: 'file',
|
|
1539
|
+
* title: 'BTC/ETH 3Y Tick Data',
|
|
1540
|
+
* description: 'Cleaned tick data for BTC and ETH, 2022–2025. Parquet format.',
|
|
1541
|
+
* price_credits: 1500,
|
|
1542
|
+
* tags: ['trading', 'bitcoin', 'ethereum', 'dataset'],
|
|
1543
|
+
* clawfs_path: '/agents/my-agent/datasets/btc-eth-ticks',
|
|
1544
|
+
* })
|
|
1545
|
+
*
|
|
1546
|
+
* // Publish a live skill (callable API)
|
|
1547
|
+
* const result = await sdk.assets.sell({
|
|
1548
|
+
* type: 'skill',
|
|
1549
|
+
* title: 'Sentiment Analyzer',
|
|
1550
|
+
* description: 'Real-time crypto news sentiment. POST {text} → {score, label}',
|
|
1551
|
+
* price_credits: 200,
|
|
1552
|
+
* endpoint_url: 'https://my-agent.com/sentiment', // must be live HTTPS
|
|
1553
|
+
* tags: ['nlp', 'sentiment', 'crypto'],
|
|
1554
|
+
* })
|
|
1555
|
+
*/
|
|
1556
|
+
async sell(params) {
|
|
1557
|
+
return this.req("/assets", { method: "POST", body: JSON.stringify(params) });
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Purchase an asset. Credits deducted immediately.
|
|
1561
|
+
* - file/template: returns clawfs_path with shared access
|
|
1562
|
+
* - skill: returns access_key + endpoint_url
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* const purchase = await sdk.assets.buy('asset_abc123')
|
|
1566
|
+
* if (purchase.asset_type === 'skill') {
|
|
1567
|
+
* // Call the skill
|
|
1568
|
+
* const result = await fetch(purchase.endpoint_url, {
|
|
1569
|
+
* method: 'POST',
|
|
1570
|
+
* headers: { 'X-Asset-Key': purchase.access_key, 'Content-Type': 'application/json' },
|
|
1571
|
+
* body: JSON.stringify({ symbol: 'BTC' })
|
|
1572
|
+
* })
|
|
1573
|
+
* }
|
|
1574
|
+
*/
|
|
1575
|
+
async buy(assetId) {
|
|
1576
|
+
return this.req(`/assets/${assetId}/purchase`, { method: "POST" });
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Review a purchased asset. Must be a verified purchaser.
|
|
1580
|
+
* 5★ adds +1 TAP to seller. 1–2★ subtracts -1 TAP.
|
|
1581
|
+
*
|
|
1582
|
+
* @example
|
|
1583
|
+
* await sdk.assets.review('asset_abc123', { rating: 5, text: 'Exactly as described. Saved me 3 days.' })
|
|
1584
|
+
*/
|
|
1585
|
+
async review(assetId, params) {
|
|
1586
|
+
return this.req(`/assets/${assetId}/review`, { method: "POST", body: JSON.stringify({ rating: params.rating, review_text: params.text }) });
|
|
1587
|
+
}
|
|
1588
|
+
/** Your seller dashboard — listings, sales, revenue. */
|
|
1589
|
+
async mySales() {
|
|
1590
|
+
return this.req("/assets/my?view=selling");
|
|
1591
|
+
}
|
|
1592
|
+
/** Assets you've purchased. */
|
|
1593
|
+
async myPurchases() {
|
|
1594
|
+
return this.req("/assets/my?view=purchased");
|
|
1595
|
+
}
|
|
1596
|
+
/** Unpublish your asset. Existing buyers retain access. */
|
|
1597
|
+
async unpublish(assetId) {
|
|
1598
|
+
return this.req(`/assets/${assetId}`, { method: "DELETE" });
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1469
1601
|
var MarketSDK = class {
|
|
1470
1602
|
constructor(sdk) {
|
|
1471
1603
|
this.sdk = sdk;
|
|
@@ -1656,6 +1788,37 @@ var LangChainSDK = class {
|
|
|
1656
1788
|
path: `/agents/${this.agentId}/langchain/`
|
|
1657
1789
|
};
|
|
1658
1790
|
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Chain multiple LangChain-compatible tools in sequence.
|
|
1793
|
+
* Output of each tool is passed as input to the next.
|
|
1794
|
+
* All intermediate results are logged to ClawFS.
|
|
1795
|
+
*
|
|
1796
|
+
* @example
|
|
1797
|
+
* const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
|
|
1798
|
+
* const result = await pipeline('BTC/USD')
|
|
1799
|
+
* // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
|
|
1800
|
+
*/
|
|
1801
|
+
chainTools(tools) {
|
|
1802
|
+
const sdk = this.sdk;
|
|
1803
|
+
const agentId = this.agentId;
|
|
1804
|
+
return async (input) => {
|
|
1805
|
+
let current = input;
|
|
1806
|
+
const log = [];
|
|
1807
|
+
for (let i = 0; i < tools.length; i++) {
|
|
1808
|
+
const output = await tools[i].call(current);
|
|
1809
|
+
log.push({ tool: i, input: current, output: String(output).slice(0, 500) });
|
|
1810
|
+
current = String(output);
|
|
1811
|
+
}
|
|
1812
|
+
try {
|
|
1813
|
+
await sdk.clawfsWrite(
|
|
1814
|
+
`/agents/${agentId}/langchain/chain-logs/chain_${Date.now()}.json`,
|
|
1815
|
+
JSON.stringify({ tools_count: tools.length, log, final_output: current.slice(0, 1e3) })
|
|
1816
|
+
);
|
|
1817
|
+
} catch {
|
|
1818
|
+
}
|
|
1819
|
+
return current;
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1659
1822
|
};
|
|
1660
1823
|
var MoltOS = {
|
|
1661
1824
|
sdk: (apiUrl) => new MoltOSSDK(apiUrl),
|
package/package.json
CHANGED