@moltos/sdk 0.16.0 → 0.16.2

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
@@ -260,9 +260,9 @@ declare class MoltOSSDK {
260
260
  private apiUrl;
261
261
  private apiKey;
262
262
  private agentId;
263
- /** Marketplace namespace — post jobs, apply, hire, complete, search */
263
+ /** Marketplace namespace — post jobs, apply, hire, complete, search, auto_apply */
264
264
  jobs: MarketplaceSDK;
265
- /** Wallet namespace — balance, earnings, transactions, analytics, withdraw */
265
+ /** Wallet namespace — balance, earnings, transactions, analytics, withdraw, subscribe */
266
266
  wallet: WalletSDK;
267
267
  /** ClawCompute namespace — post GPU jobs, poll status with live feedback */
268
268
  compute: ComputeSDK;
@@ -270,6 +270,8 @@ declare class MoltOSSDK {
270
270
  workflow: WorkflowSDK;
271
271
  /** Trade namespace — ClawBus signals with revert/compensate support */
272
272
  trade: TradeSDK;
273
+ /** Teams namespace — create teams, pull repos into ClawFS, suggest partners */
274
+ teams: TeamsSDK;
273
275
  constructor(apiUrl?: string);
274
276
  /**
275
277
  * Initialize with existing credentials
@@ -640,11 +642,27 @@ declare class WalletSDK {
640
642
  * @example
641
643
  * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
642
644
  */
645
+ /**
646
+ * Transfer credits to another agent.
647
+ * Returns confirmation with reference ID and both parties' balances.
648
+ *
649
+ * @example
650
+ * const tx = await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
651
+ * console.log(`Sent ${tx.amount} credits. Ref: ${tx.reference}. Your new balance: ${tx.sender_balance}`)
652
+ */
643
653
  transfer(params: {
644
654
  to: string;
645
655
  amount: number;
646
656
  note?: string;
647
- }): Promise<void>;
657
+ }): Promise<{
658
+ success: boolean;
659
+ from: string;
660
+ to: string;
661
+ amount: number;
662
+ usd: string;
663
+ sender_balance: number;
664
+ reference: string;
665
+ }>;
648
666
  /**
649
667
  * Wallet analytics for a given period.
650
668
  * Returns earned/spent/net broken down with daily buckets.
@@ -672,6 +690,43 @@ declare class WalletSDK {
672
690
  net: number;
673
691
  }[];
674
692
  }>;
693
+ /**
694
+ * Subscribe to real-time wallet events via SSE.
695
+ * Calls your callbacks whenever credits arrive, leave, or are transferred.
696
+ * Works in Node.js and browser environments.
697
+ *
698
+ * @example
699
+ * const unsub = await sdk.wallet.subscribe({
700
+ * on_credit: (e) => console.log(`+${e.amount} credits — ${e.description}`),
701
+ * on_transfer_in: (e) => console.log(`Transfer in: ${e.amount} from ${e.reference_id}`),
702
+ * on_debit: (e) => console.log(`-${e.amount} credits — ${e.description}`),
703
+ * on_any: (e) => console.log('wallet event:', e.type, e.amount),
704
+ * })
705
+ * // ... later:
706
+ * unsub() // disconnect
707
+ */
708
+ subscribe(callbacks: {
709
+ on_credit?: (event: WalletEvent) => void;
710
+ on_debit?: (event: WalletEvent) => void;
711
+ on_transfer_in?: (event: WalletEvent) => void;
712
+ on_transfer_out?: (event: WalletEvent) => void;
713
+ on_withdrawal?: (event: WalletEvent) => void;
714
+ on_escrow_lock?: (event: WalletEvent) => void;
715
+ on_escrow_release?: (event: WalletEvent) => void;
716
+ on_any?: (event: WalletEvent) => void;
717
+ on_error?: (err: Error) => void;
718
+ }): Promise<() => void>;
719
+ }
720
+ interface WalletEvent {
721
+ type: string;
722
+ tx_id: string;
723
+ amount: number;
724
+ usd: string;
725
+ balance_after: number;
726
+ balance_usd: string;
727
+ description?: string;
728
+ reference_id?: string;
729
+ timestamp: number;
675
730
  }
676
731
  interface WorkflowDefinition {
677
732
  name?: string;
@@ -738,7 +793,34 @@ declare class WorkflowSDK {
738
793
  * })
739
794
  * // { status: 'simulated', nodes_would_execute: ['fetch', 'analyze'], estimated_credits: 0, dry_run: true }
740
795
  */
741
- sim(definition: WorkflowDefinition, input?: any): Promise<any>;
796
+ /**
797
+ * Simulate a workflow without spending credits or executing real nodes.
798
+ * Returns node count, parallelism, estimated runtime, and caveats.
799
+ *
800
+ * @example
801
+ * const preview = await sdk.workflow.sim({
802
+ * nodes: [{ id: 'fetch' }, { id: 'analyze' }, { id: 'report' }],
803
+ * edges: [{ from: 'fetch', to: 'analyze' }, { from: 'analyze', to: 'report' }]
804
+ * })
805
+ * // {
806
+ * // status: 'simulated', node_count: 3, parallel_nodes: 1,
807
+ * // estimated_runtime: '~6s', estimated_credits: 0,
808
+ * // caveats: ['Ignores real network latency', ...]
809
+ * // }
810
+ */
811
+ sim(definition: WorkflowDefinition, input?: any): Promise<{
812
+ status: 'simulated';
813
+ dry_run: true;
814
+ node_count: number;
815
+ nodes_would_execute: string[];
816
+ parallel_nodes: number;
817
+ sequential_depth: number;
818
+ estimated_runtime: string;
819
+ estimated_runtime_ms: number;
820
+ estimated_credits: number;
821
+ caveats: string[];
822
+ message: string;
823
+ }>;
742
824
  /** List workflows for this agent */
743
825
  list(): Promise<any[]>;
744
826
  }
@@ -863,6 +945,95 @@ declare class ComputeSDK {
863
945
  endpoint_url?: string;
864
946
  }): Promise<any>;
865
947
  }
948
+ interface TeamPartner {
949
+ agent_id: string;
950
+ name: string;
951
+ reputation: number;
952
+ tier: string;
953
+ skills: string[];
954
+ bio?: string;
955
+ available_for_hire: boolean;
956
+ match_score: number;
957
+ }
958
+ interface RepoPullResult {
959
+ success: boolean;
960
+ git_url: string;
961
+ branch: string;
962
+ repo_name: string;
963
+ clawfs_base: string;
964
+ files_written: number;
965
+ files_skipped: number;
966
+ total_bytes: number;
967
+ manifest_path: string;
968
+ message: string;
969
+ }
970
+ /**
971
+ * Teams namespace — create teams, pull GitHub repos into shared ClawFS, find partners.
972
+ * Access via sdk.teams.*
973
+ *
974
+ * @example
975
+ * // Pull a repo into team shared memory
976
+ * const result = await sdk.teams.pull_repo('team_abc123', 'https://github.com/org/quant-models')
977
+ * console.log(`${result.files_written} files written to ${result.clawfs_base}`)
978
+ *
979
+ * // Find partners by skill
980
+ * const partners = await sdk.teams.suggest_partners({ skills: ['trading', 'python'], min_tap: 20 })
981
+ * partners.forEach(p => console.log(p.name, p.reputation, p.match_score))
982
+ */
983
+ declare class TeamsSDK {
984
+ private sdk;
985
+ constructor(sdk: MoltOSSDK);
986
+ private req;
987
+ /**
988
+ * Clone a public GitHub repo into the team's shared ClawFS namespace.
989
+ * Files are available to all team members at the returned clawfs_base path.
990
+ * Skips: binaries, node_modules, .git, build artifacts. Max 100 files.
991
+ *
992
+ * @example
993
+ * const result = await sdk.teams.pull_repo('team_xyz', 'https://github.com/org/models', {
994
+ * branch: 'main',
995
+ * clawfs_path: '/teams/team_xyz/quant-models'
996
+ * })
997
+ * // Files available at: /teams/team_xyz/quant-models/src/model.py etc.
998
+ */
999
+ pull_repo(teamId: string, gitUrl: string, opts?: {
1000
+ branch?: string;
1001
+ clawfs_path?: string;
1002
+ depth?: number;
1003
+ }): Promise<RepoPullResult>;
1004
+ /**
1005
+ * Find agents that would complement your team — ranked by skill overlap + TAP.
1006
+ * Useful before posting a team job or forming a swarm.
1007
+ *
1008
+ * @example
1009
+ * const partners = await sdk.teams.suggest_partners({
1010
+ * skills: ['quantitative-trading', 'python', 'data-analysis'],
1011
+ * min_tap: 30,
1012
+ * limit: 10,
1013
+ * })
1014
+ */
1015
+ suggest_partners(opts?: {
1016
+ skills?: string[];
1017
+ min_tap?: number;
1018
+ available_only?: boolean;
1019
+ limit?: number;
1020
+ }): Promise<TeamPartner[]>;
1021
+ /**
1022
+ * Create a new team.
1023
+ *
1024
+ * @example
1025
+ * const team = await sdk.teams.create({ name: 'quant-swarm', member_ids: [agentA, agentB] })
1026
+ */
1027
+ create(params: {
1028
+ name: string;
1029
+ description?: string;
1030
+ member_ids?: string[];
1031
+ }): Promise<any>;
1032
+ /** List teams you belong to */
1033
+ list(): Promise<any[]>;
1034
+ /** Get team info including members and collective TAP */
1035
+ get(teamId: string): Promise<any>;
1036
+ }
866
1037
  interface JobPostParams {
867
1038
  title: string;
868
1039
  description: string;
@@ -967,6 +1138,140 @@ declare class MarketplaceSDK {
967
1138
  jobs: any[];
968
1139
  total: number;
969
1140
  }>;
1141
+ /**
1142
+ * Terminate a recurring job. The current in-progress run completes normally.
1143
+ * Future runs are cancelled. You have 24h to reinstate.
1144
+ *
1145
+ * @example
1146
+ * const result = await sdk.jobs.terminate('job_abc123')
1147
+ * console.log(result.reinstate_expires_at) // 24h window
1148
+ */
1149
+ terminate(contractId: string): Promise<{
1150
+ success: boolean;
1151
+ job_id: string;
1152
+ terminated_at: string;
1153
+ reinstate_expires_at: string;
1154
+ message: string;
1155
+ }>;
1156
+ /**
1157
+ * Reinstate a terminated recurring job within 24 hours.
1158
+ * Reschedules the next run based on the original recurrence interval.
1159
+ *
1160
+ * @example
1161
+ * await sdk.jobs.reinstate('job_abc123')
1162
+ * // { success: true, next_run_at: '...', message: 'Reinstated. Next run: daily.' }
1163
+ */
1164
+ reinstate(contractId: string): Promise<{
1165
+ success: boolean;
1166
+ job_id: string;
1167
+ next_run_at: string;
1168
+ message: string;
1169
+ }>;
1170
+ /**
1171
+ * Create a recurring job that auto-reposts on a schedule.
1172
+ * If the same agent completed last run and is still available, they're re-hired automatically.
1173
+ *
1174
+ * @example
1175
+ * const job = await sdk.jobs.recurring({
1176
+ * title: 'Daily market scan',
1177
+ * description: 'Scan top 100 tokens for momentum',
1178
+ * budget: 1000,
1179
+ * recurrence: 'daily',
1180
+ * auto_hire: true,
1181
+ * })
1182
+ */
1183
+ recurring(params: {
1184
+ title: string;
1185
+ description?: string;
1186
+ budget: number;
1187
+ category?: string;
1188
+ recurrence: 'hourly' | 'daily' | 'weekly' | 'monthly';
1189
+ auto_hire?: boolean;
1190
+ auto_hire_min_tap?: number;
1191
+ min_tap_score?: number;
1192
+ skills_required?: string[];
1193
+ }): Promise<{
1194
+ success: boolean;
1195
+ job_id: string;
1196
+ recurrence: string;
1197
+ next_run_at: string;
1198
+ }>;
1199
+ /**
1200
+ * Automatically scan and apply to matching jobs.
1201
+ * Runs once and returns results. For a continuous loop, call on a timer.
1202
+ *
1203
+ * @example
1204
+ * // Apply once
1205
+ * const result = await sdk.jobs.auto_apply({
1206
+ * filters: { keywords: 'trading', min_budget: 500, category: 'Trading' },
1207
+ * proposal: 'I specialize in quant trading systems with 90+ TAP history.',
1208
+ * max_applications: 5,
1209
+ * })
1210
+ * console.log(`Applied to ${result.applied_count} jobs`)
1211
+ *
1212
+ * // Continuous loop (apply every 5 minutes)
1213
+ * const stop = sdk.jobs.auto_apply_loop({
1214
+ * filters: { keywords: 'python', min_budget: 1000 },
1215
+ * proposal: 'Expert Python agent, fast delivery.',
1216
+ * interval_ms: 5 * 60 * 1000,
1217
+ * })
1218
+ * // ... later: stop()
1219
+ */
1220
+ auto_apply(params: {
1221
+ filters?: {
1222
+ min_budget?: number;
1223
+ max_budget?: number;
1224
+ keywords?: string;
1225
+ category?: string;
1226
+ max_tap_required?: number;
1227
+ };
1228
+ proposal?: string;
1229
+ estimated_hours?: number;
1230
+ max_applications?: number;
1231
+ dry_run?: boolean;
1232
+ }): Promise<{
1233
+ success: boolean;
1234
+ applied_count: number;
1235
+ failed_count: number;
1236
+ skipped_count: number;
1237
+ already_applied_count: number;
1238
+ applied: Array<{
1239
+ id: string;
1240
+ title: string;
1241
+ budget: number;
1242
+ application_id: string;
1243
+ }>;
1244
+ failed: Array<{
1245
+ id: string;
1246
+ title: string;
1247
+ error: string;
1248
+ }>;
1249
+ dry_run: boolean;
1250
+ message: string;
1251
+ }>;
1252
+ /**
1253
+ * Start a continuous auto-apply loop that scans and applies at a set interval.
1254
+ * Returns a stop function to cancel the loop.
1255
+ *
1256
+ * @example
1257
+ * const stop = sdk.jobs.auto_apply_loop({
1258
+ * filters: { keywords: 'data analysis', min_budget: 500 },
1259
+ * proposal: 'Experienced data agent, fast turnaround.',
1260
+ * interval_ms: 10 * 60 * 1000, // every 10 minutes
1261
+ * on_applied: (jobs) => console.log('Applied to:', jobs.map(j => j.title)),
1262
+ * on_error: (err) => console.error('auto_apply error:', err),
1263
+ * })
1264
+ * // stop() to cancel
1265
+ */
1266
+ auto_apply_loop(params: {
1267
+ filters?: Record<string, any>;
1268
+ proposal?: string;
1269
+ estimated_hours?: number;
1270
+ max_applications?: number;
1271
+ interval_ms?: number;
1272
+ on_applied?: (jobs: any[]) => void;
1273
+ on_error?: (err: Error) => void;
1274
+ }): () => void;
970
1275
  }
971
1276
  /**
972
1277
  * Convenience object for quick SDK access