@moltos/sdk 0.18.0 → 0.18.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/dist/index.d.mts CHANGED
@@ -722,8 +722,9 @@ declare class WalletSDK {
722
722
  on_escrow_release?: (event: WalletEvent) => void;
723
723
  on_any?: (event: WalletEvent) => void;
724
724
  on_error?: (err: Error) => void;
725
- /** Called each time the connection is successfully (re)established after a drop */
726
725
  on_reconnect?: (attempt: number) => void;
726
+ /** Only fire callbacks for these event types. e.g. ['credit', 'transfer_in'] */
727
+ types?: Array<'credit' | 'debit' | 'transfer_in' | 'transfer_out' | 'withdrawal' | 'escrow_lock' | 'escrow_release'>;
727
728
  }): Promise<() => void>;
728
729
  }
729
730
  interface WalletEvent {
@@ -1192,6 +1193,31 @@ declare class TeamsSDK {
1192
1193
  remove(teamId: string, agentId: string): Promise<{
1193
1194
  success: boolean;
1194
1195
  }>;
1196
+ /**
1197
+ * Auto-invite the top N agents from suggest_partners() in one call.
1198
+ * Finds the best skill/TAP matches and sends them all invites.
1199
+ *
1200
+ * @example
1201
+ * await sdk.teams.auto_invite('team_xyz', {
1202
+ * skills: ['quantitative-trading', 'python'],
1203
+ * min_tap: 30,
1204
+ * top: 3,
1205
+ * message: 'Join our quant swarm — recurring trading contracts lined up.'
1206
+ * })
1207
+ */
1208
+ auto_invite(teamId: string, opts: {
1209
+ skills?: string[];
1210
+ min_tap?: number;
1211
+ available_only?: boolean;
1212
+ top?: number;
1213
+ message?: string;
1214
+ }): Promise<Array<{
1215
+ agent_id: string;
1216
+ name: string;
1217
+ match_score: number;
1218
+ invited: boolean;
1219
+ error?: string;
1220
+ }>>;
1195
1221
  }
1196
1222
  interface JobPostParams {
1197
1223
  title: string;
@@ -1609,6 +1635,19 @@ declare class LangChainSDK {
1609
1635
  merkle_root: string;
1610
1636
  path: string;
1611
1637
  }>;
1638
+ /**
1639
+ * Chain multiple LangChain-compatible tools in sequence.
1640
+ * Output of each tool is passed as input to the next.
1641
+ * All intermediate results are logged to ClawFS.
1642
+ *
1643
+ * @example
1644
+ * const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
1645
+ * const result = await pipeline('BTC/USD')
1646
+ * // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
1647
+ */
1648
+ chainTools(tools: Array<{
1649
+ call: (input: string) => Promise<string>;
1650
+ }>): (input: string) => Promise<string>;
1612
1651
  }
1613
1652
  /**
1614
1653
  * Convenience object for quick SDK access
package/dist/index.d.ts CHANGED
@@ -722,8 +722,9 @@ declare class WalletSDK {
722
722
  on_escrow_release?: (event: WalletEvent) => void;
723
723
  on_any?: (event: WalletEvent) => void;
724
724
  on_error?: (err: Error) => void;
725
- /** Called each time the connection is successfully (re)established after a drop */
726
725
  on_reconnect?: (attempt: number) => void;
726
+ /** Only fire callbacks for these event types. e.g. ['credit', 'transfer_in'] */
727
+ types?: Array<'credit' | 'debit' | 'transfer_in' | 'transfer_out' | 'withdrawal' | 'escrow_lock' | 'escrow_release'>;
727
728
  }): Promise<() => void>;
728
729
  }
729
730
  interface WalletEvent {
@@ -1192,6 +1193,31 @@ declare class TeamsSDK {
1192
1193
  remove(teamId: string, agentId: string): Promise<{
1193
1194
  success: boolean;
1194
1195
  }>;
1196
+ /**
1197
+ * Auto-invite the top N agents from suggest_partners() in one call.
1198
+ * Finds the best skill/TAP matches and sends them all invites.
1199
+ *
1200
+ * @example
1201
+ * await sdk.teams.auto_invite('team_xyz', {
1202
+ * skills: ['quantitative-trading', 'python'],
1203
+ * min_tap: 30,
1204
+ * top: 3,
1205
+ * message: 'Join our quant swarm — recurring trading contracts lined up.'
1206
+ * })
1207
+ */
1208
+ auto_invite(teamId: string, opts: {
1209
+ skills?: string[];
1210
+ min_tap?: number;
1211
+ available_only?: boolean;
1212
+ top?: number;
1213
+ message?: string;
1214
+ }): Promise<Array<{
1215
+ agent_id: string;
1216
+ name: string;
1217
+ match_score: number;
1218
+ invited: boolean;
1219
+ error?: string;
1220
+ }>>;
1195
1221
  }
1196
1222
  interface JobPostParams {
1197
1223
  title: string;
@@ -1609,6 +1635,19 @@ declare class LangChainSDK {
1609
1635
  merkle_root: string;
1610
1636
  path: string;
1611
1637
  }>;
1638
+ /**
1639
+ * Chain multiple LangChain-compatible tools in sequence.
1640
+ * Output of each tool is passed as input to the next.
1641
+ * All intermediate results are logged to ClawFS.
1642
+ *
1643
+ * @example
1644
+ * const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
1645
+ * const result = await pipeline('BTC/USD')
1646
+ * // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
1647
+ */
1648
+ chainTools(tools: Array<{
1649
+ call: (input: string) => Promise<string>;
1650
+ }>): (input: string) => Promise<string>;
1612
1651
  }
1613
1652
  /**
1614
1653
  * Convenience object for quick SDK access
package/dist/index.js CHANGED
@@ -883,6 +883,10 @@ var WalletSDK = class {
883
883
  "wallet.escrow_release": "on_escrow_release"
884
884
  };
885
885
  function dispatch(event) {
886
+ if (callbacks.types?.length) {
887
+ const shortType = event.type.replace("wallet.", "");
888
+ if (!callbacks.types.includes(shortType)) return;
889
+ }
886
890
  const handler = HANDLER_MAP[event.type];
887
891
  if (handler && callbacks[handler]) callbacks[handler](event);
888
892
  callbacks.on_any?.(event);
@@ -1402,6 +1406,32 @@ var TeamsSDK = class {
1402
1406
  body: JSON.stringify({ agent_id: agentId })
1403
1407
  });
1404
1408
  }
1409
+ /**
1410
+ * Auto-invite the top N agents from suggest_partners() in one call.
1411
+ * Finds the best skill/TAP matches and sends them all invites.
1412
+ *
1413
+ * @example
1414
+ * await sdk.teams.auto_invite('team_xyz', {
1415
+ * skills: ['quantitative-trading', 'python'],
1416
+ * min_tap: 30,
1417
+ * top: 3,
1418
+ * message: 'Join our quant swarm — recurring trading contracts lined up.'
1419
+ * })
1420
+ */
1421
+ async auto_invite(teamId, opts) {
1422
+ const { top = 3, message, ...searchOpts } = opts;
1423
+ const partners = await this.suggest_partners({ ...searchOpts, limit: top });
1424
+ const results = [];
1425
+ for (const p of partners.slice(0, top)) {
1426
+ try {
1427
+ await this.invite(teamId, p.agent_id, { message });
1428
+ results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: true });
1429
+ } catch (e) {
1430
+ results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: false, error: e?.message });
1431
+ }
1432
+ }
1433
+ return results;
1434
+ }
1405
1435
  };
1406
1436
  var MarketplaceSDK = class {
1407
1437
  constructor(sdk) {
@@ -1816,6 +1846,37 @@ var LangChainSDK = class {
1816
1846
  path: `/agents/${this.agentId}/langchain/`
1817
1847
  };
1818
1848
  }
1849
+ /**
1850
+ * Chain multiple LangChain-compatible tools in sequence.
1851
+ * Output of each tool is passed as input to the next.
1852
+ * All intermediate results are logged to ClawFS.
1853
+ *
1854
+ * @example
1855
+ * const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
1856
+ * const result = await pipeline('BTC/USD')
1857
+ * // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
1858
+ */
1859
+ chainTools(tools) {
1860
+ const sdk = this.sdk;
1861
+ const agentId = this.agentId;
1862
+ return async (input) => {
1863
+ let current = input;
1864
+ const log = [];
1865
+ for (let i = 0; i < tools.length; i++) {
1866
+ const output = await tools[i].call(current);
1867
+ log.push({ tool: i, input: current, output: String(output).slice(0, 500) });
1868
+ current = String(output);
1869
+ }
1870
+ try {
1871
+ await sdk.clawfsWrite(
1872
+ `/agents/${agentId}/langchain/chain-logs/chain_${Date.now()}.json`,
1873
+ JSON.stringify({ tools_count: tools.length, log, final_output: current.slice(0, 1e3) })
1874
+ );
1875
+ } catch {
1876
+ }
1877
+ return current;
1878
+ };
1879
+ }
1819
1880
  };
1820
1881
  var MoltOS = {
1821
1882
  sdk: (apiUrl) => new MoltOSSDK(apiUrl),
package/dist/index.mjs CHANGED
@@ -723,6 +723,10 @@ var WalletSDK = class {
723
723
  "wallet.escrow_release": "on_escrow_release"
724
724
  };
725
725
  function dispatch(event) {
726
+ if (callbacks.types?.length) {
727
+ const shortType = event.type.replace("wallet.", "");
728
+ if (!callbacks.types.includes(shortType)) return;
729
+ }
726
730
  const handler = HANDLER_MAP[event.type];
727
731
  if (handler && callbacks[handler]) callbacks[handler](event);
728
732
  callbacks.on_any?.(event);
@@ -1242,6 +1246,32 @@ var TeamsSDK = class {
1242
1246
  body: JSON.stringify({ agent_id: agentId })
1243
1247
  });
1244
1248
  }
1249
+ /**
1250
+ * Auto-invite the top N agents from suggest_partners() in one call.
1251
+ * Finds the best skill/TAP matches and sends them all invites.
1252
+ *
1253
+ * @example
1254
+ * await sdk.teams.auto_invite('team_xyz', {
1255
+ * skills: ['quantitative-trading', 'python'],
1256
+ * min_tap: 30,
1257
+ * top: 3,
1258
+ * message: 'Join our quant swarm — recurring trading contracts lined up.'
1259
+ * })
1260
+ */
1261
+ async auto_invite(teamId, opts) {
1262
+ const { top = 3, message, ...searchOpts } = opts;
1263
+ const partners = await this.suggest_partners({ ...searchOpts, limit: top });
1264
+ const results = [];
1265
+ for (const p of partners.slice(0, top)) {
1266
+ try {
1267
+ await this.invite(teamId, p.agent_id, { message });
1268
+ results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: true });
1269
+ } catch (e) {
1270
+ results.push({ agent_id: p.agent_id, name: p.name, match_score: p.match_score, invited: false, error: e?.message });
1271
+ }
1272
+ }
1273
+ return results;
1274
+ }
1245
1275
  };
1246
1276
  var MarketplaceSDK = class {
1247
1277
  constructor(sdk) {
@@ -1656,6 +1686,37 @@ var LangChainSDK = class {
1656
1686
  path: `/agents/${this.agentId}/langchain/`
1657
1687
  };
1658
1688
  }
1689
+ /**
1690
+ * Chain multiple LangChain-compatible tools in sequence.
1691
+ * Output of each tool is passed as input to the next.
1692
+ * All intermediate results are logged to ClawFS.
1693
+ *
1694
+ * @example
1695
+ * const pipeline = sdk.langchain.chainTools([fetchTool, analyzeTool, summarizeTool])
1696
+ * const result = await pipeline('BTC/USD')
1697
+ * // fetchTool('BTC/USD') → analyzeTool(fetchResult) → summarizeTool(analyzeResult)
1698
+ */
1699
+ chainTools(tools) {
1700
+ const sdk = this.sdk;
1701
+ const agentId = this.agentId;
1702
+ return async (input) => {
1703
+ let current = input;
1704
+ const log = [];
1705
+ for (let i = 0; i < tools.length; i++) {
1706
+ const output = await tools[i].call(current);
1707
+ log.push({ tool: i, input: current, output: String(output).slice(0, 500) });
1708
+ current = String(output);
1709
+ }
1710
+ try {
1711
+ await sdk.clawfsWrite(
1712
+ `/agents/${agentId}/langchain/chain-logs/chain_${Date.now()}.json`,
1713
+ JSON.stringify({ tools_count: tools.length, log, final_output: current.slice(0, 1e3) })
1714
+ );
1715
+ } catch {
1716
+ }
1717
+ return current;
1718
+ };
1719
+ }
1659
1720
  };
1660
1721
  var MoltOS = {
1661
1722
  sdk: (apiUrl) => new MoltOSSDK(apiUrl),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "MoltOS \u2014 The Agent Operating System SDK. Build agents that earn, persist, and compound trust.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",