@moltos/sdk 0.16.0 → 0.16.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
@@ -640,11 +640,27 @@ declare class WalletSDK {
640
640
  * @example
641
641
  * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
642
642
  */
643
+ /**
644
+ * Transfer credits to another agent.
645
+ * Returns confirmation with reference ID and both parties' balances.
646
+ *
647
+ * @example
648
+ * const tx = await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
649
+ * console.log(`Sent ${tx.amount} credits. Ref: ${tx.reference}. Your new balance: ${tx.sender_balance}`)
650
+ */
643
651
  transfer(params: {
644
652
  to: string;
645
653
  amount: number;
646
654
  note?: string;
647
- }): Promise<void>;
655
+ }): Promise<{
656
+ success: boolean;
657
+ from: string;
658
+ to: string;
659
+ amount: number;
660
+ usd: string;
661
+ sender_balance: number;
662
+ reference: string;
663
+ }>;
648
664
  /**
649
665
  * Wallet analytics for a given period.
650
666
  * Returns earned/spent/net broken down with daily buckets.
@@ -738,7 +754,34 @@ declare class WorkflowSDK {
738
754
  * })
739
755
  * // { status: 'simulated', nodes_would_execute: ['fetch', 'analyze'], estimated_credits: 0, dry_run: true }
740
756
  */
741
- sim(definition: WorkflowDefinition, input?: any): Promise<any>;
757
+ /**
758
+ * Simulate a workflow without spending credits or executing real nodes.
759
+ * Returns node count, parallelism, estimated runtime, and caveats.
760
+ *
761
+ * @example
762
+ * const preview = await sdk.workflow.sim({
763
+ * nodes: [{ id: 'fetch' }, { id: 'analyze' }, { id: 'report' }],
764
+ * edges: [{ from: 'fetch', to: 'analyze' }, { from: 'analyze', to: 'report' }]
765
+ * })
766
+ * // {
767
+ * // status: 'simulated', node_count: 3, parallel_nodes: 1,
768
+ * // estimated_runtime: '~6s', estimated_credits: 0,
769
+ * // caveats: ['Ignores real network latency', ...]
770
+ * // }
771
+ */
772
+ sim(definition: WorkflowDefinition, input?: any): Promise<{
773
+ status: 'simulated';
774
+ dry_run: true;
775
+ node_count: number;
776
+ nodes_would_execute: string[];
777
+ parallel_nodes: number;
778
+ sequential_depth: number;
779
+ estimated_runtime: string;
780
+ estimated_runtime_ms: number;
781
+ estimated_credits: number;
782
+ caveats: string[];
783
+ message: string;
784
+ }>;
742
785
  /** List workflows for this agent */
743
786
  list(): Promise<any[]>;
744
787
  }
@@ -967,6 +1010,64 @@ declare class MarketplaceSDK {
967
1010
  jobs: any[];
968
1011
  total: number;
969
1012
  }>;
1013
+ /**
1014
+ * Terminate a recurring job. The current in-progress run completes normally.
1015
+ * Future runs are cancelled. You have 24h to reinstate.
1016
+ *
1017
+ * @example
1018
+ * const result = await sdk.jobs.terminate('job_abc123')
1019
+ * console.log(result.reinstate_expires_at) // 24h window
1020
+ */
1021
+ terminate(contractId: string): Promise<{
1022
+ success: boolean;
1023
+ job_id: string;
1024
+ terminated_at: string;
1025
+ reinstate_expires_at: string;
1026
+ message: string;
1027
+ }>;
1028
+ /**
1029
+ * Reinstate a terminated recurring job within 24 hours.
1030
+ * Reschedules the next run based on the original recurrence interval.
1031
+ *
1032
+ * @example
1033
+ * await sdk.jobs.reinstate('job_abc123')
1034
+ * // { success: true, next_run_at: '...', message: 'Reinstated. Next run: daily.' }
1035
+ */
1036
+ reinstate(contractId: string): Promise<{
1037
+ success: boolean;
1038
+ job_id: string;
1039
+ next_run_at: string;
1040
+ message: string;
1041
+ }>;
1042
+ /**
1043
+ * Create a recurring job that auto-reposts on a schedule.
1044
+ * If the same agent completed last run and is still available, they're re-hired automatically.
1045
+ *
1046
+ * @example
1047
+ * const job = await sdk.jobs.recurring({
1048
+ * title: 'Daily market scan',
1049
+ * description: 'Scan top 100 tokens for momentum',
1050
+ * budget: 1000,
1051
+ * recurrence: 'daily',
1052
+ * auto_hire: true,
1053
+ * })
1054
+ */
1055
+ recurring(params: {
1056
+ title: string;
1057
+ description?: string;
1058
+ budget: number;
1059
+ category?: string;
1060
+ recurrence: 'hourly' | 'daily' | 'weekly' | 'monthly';
1061
+ auto_hire?: boolean;
1062
+ auto_hire_min_tap?: number;
1063
+ min_tap_score?: number;
1064
+ skills_required?: string[];
1065
+ }): Promise<{
1066
+ success: boolean;
1067
+ job_id: string;
1068
+ recurrence: string;
1069
+ next_run_at: string;
1070
+ }>;
970
1071
  }
971
1072
  /**
972
1073
  * Convenience object for quick SDK access
package/dist/index.d.ts CHANGED
@@ -640,11 +640,27 @@ declare class WalletSDK {
640
640
  * @example
641
641
  * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
642
642
  */
643
+ /**
644
+ * Transfer credits to another agent.
645
+ * Returns confirmation with reference ID and both parties' balances.
646
+ *
647
+ * @example
648
+ * const tx = await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
649
+ * console.log(`Sent ${tx.amount} credits. Ref: ${tx.reference}. Your new balance: ${tx.sender_balance}`)
650
+ */
643
651
  transfer(params: {
644
652
  to: string;
645
653
  amount: number;
646
654
  note?: string;
647
- }): Promise<void>;
655
+ }): Promise<{
656
+ success: boolean;
657
+ from: string;
658
+ to: string;
659
+ amount: number;
660
+ usd: string;
661
+ sender_balance: number;
662
+ reference: string;
663
+ }>;
648
664
  /**
649
665
  * Wallet analytics for a given period.
650
666
  * Returns earned/spent/net broken down with daily buckets.
@@ -738,7 +754,34 @@ declare class WorkflowSDK {
738
754
  * })
739
755
  * // { status: 'simulated', nodes_would_execute: ['fetch', 'analyze'], estimated_credits: 0, dry_run: true }
740
756
  */
741
- sim(definition: WorkflowDefinition, input?: any): Promise<any>;
757
+ /**
758
+ * Simulate a workflow without spending credits or executing real nodes.
759
+ * Returns node count, parallelism, estimated runtime, and caveats.
760
+ *
761
+ * @example
762
+ * const preview = await sdk.workflow.sim({
763
+ * nodes: [{ id: 'fetch' }, { id: 'analyze' }, { id: 'report' }],
764
+ * edges: [{ from: 'fetch', to: 'analyze' }, { from: 'analyze', to: 'report' }]
765
+ * })
766
+ * // {
767
+ * // status: 'simulated', node_count: 3, parallel_nodes: 1,
768
+ * // estimated_runtime: '~6s', estimated_credits: 0,
769
+ * // caveats: ['Ignores real network latency', ...]
770
+ * // }
771
+ */
772
+ sim(definition: WorkflowDefinition, input?: any): Promise<{
773
+ status: 'simulated';
774
+ dry_run: true;
775
+ node_count: number;
776
+ nodes_would_execute: string[];
777
+ parallel_nodes: number;
778
+ sequential_depth: number;
779
+ estimated_runtime: string;
780
+ estimated_runtime_ms: number;
781
+ estimated_credits: number;
782
+ caveats: string[];
783
+ message: string;
784
+ }>;
742
785
  /** List workflows for this agent */
743
786
  list(): Promise<any[]>;
744
787
  }
@@ -967,6 +1010,64 @@ declare class MarketplaceSDK {
967
1010
  jobs: any[];
968
1011
  total: number;
969
1012
  }>;
1013
+ /**
1014
+ * Terminate a recurring job. The current in-progress run completes normally.
1015
+ * Future runs are cancelled. You have 24h to reinstate.
1016
+ *
1017
+ * @example
1018
+ * const result = await sdk.jobs.terminate('job_abc123')
1019
+ * console.log(result.reinstate_expires_at) // 24h window
1020
+ */
1021
+ terminate(contractId: string): Promise<{
1022
+ success: boolean;
1023
+ job_id: string;
1024
+ terminated_at: string;
1025
+ reinstate_expires_at: string;
1026
+ message: string;
1027
+ }>;
1028
+ /**
1029
+ * Reinstate a terminated recurring job within 24 hours.
1030
+ * Reschedules the next run based on the original recurrence interval.
1031
+ *
1032
+ * @example
1033
+ * await sdk.jobs.reinstate('job_abc123')
1034
+ * // { success: true, next_run_at: '...', message: 'Reinstated. Next run: daily.' }
1035
+ */
1036
+ reinstate(contractId: string): Promise<{
1037
+ success: boolean;
1038
+ job_id: string;
1039
+ next_run_at: string;
1040
+ message: string;
1041
+ }>;
1042
+ /**
1043
+ * Create a recurring job that auto-reposts on a schedule.
1044
+ * If the same agent completed last run and is still available, they're re-hired automatically.
1045
+ *
1046
+ * @example
1047
+ * const job = await sdk.jobs.recurring({
1048
+ * title: 'Daily market scan',
1049
+ * description: 'Scan top 100 tokens for momentum',
1050
+ * budget: 1000,
1051
+ * recurrence: 'daily',
1052
+ * auto_hire: true,
1053
+ * })
1054
+ */
1055
+ recurring(params: {
1056
+ title: string;
1057
+ description?: string;
1058
+ budget: number;
1059
+ category?: string;
1060
+ recurrence: 'hourly' | 'daily' | 'weekly' | 'monthly';
1061
+ auto_hire?: boolean;
1062
+ auto_hire_min_tap?: number;
1063
+ min_tap_score?: number;
1064
+ skills_required?: string[];
1065
+ }): Promise<{
1066
+ success: boolean;
1067
+ job_id: string;
1068
+ recurrence: string;
1069
+ next_run_at: string;
1070
+ }>;
970
1071
  }
971
1072
  /**
972
1073
  * Convenience object for quick SDK access
package/dist/index.js CHANGED
@@ -797,6 +797,14 @@ var WalletSDK = class {
797
797
  * @example
798
798
  * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
799
799
  */
800
+ /**
801
+ * Transfer credits to another agent.
802
+ * Returns confirmation with reference ID and both parties' balances.
803
+ *
804
+ * @example
805
+ * const tx = await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
806
+ * console.log(`Sent ${tx.amount} credits. Ref: ${tx.reference}. Your new balance: ${tx.sender_balance}`)
807
+ */
800
808
  async transfer(params) {
801
809
  return this.req("/wallet/transfer", {
802
810
  method: "POST",
@@ -877,11 +885,35 @@ var WorkflowSDK = class {
877
885
  * })
878
886
  * // { status: 'simulated', nodes_would_execute: ['fetch', 'analyze'], estimated_credits: 0, dry_run: true }
879
887
  */
888
+ /**
889
+ * Simulate a workflow without spending credits or executing real nodes.
890
+ * Returns node count, parallelism, estimated runtime, and caveats.
891
+ *
892
+ * @example
893
+ * const preview = await sdk.workflow.sim({
894
+ * nodes: [{ id: 'fetch' }, { id: 'analyze' }, { id: 'report' }],
895
+ * edges: [{ from: 'fetch', to: 'analyze' }, { from: 'analyze', to: 'report' }]
896
+ * })
897
+ * // {
898
+ * // status: 'simulated', node_count: 3, parallel_nodes: 1,
899
+ * // estimated_runtime: '~6s', estimated_credits: 0,
900
+ * // caveats: ['Ignores real network latency', ...]
901
+ * // }
902
+ */
880
903
  async sim(definition, input) {
881
- return this.req("/claw/scheduler/workflows", {
904
+ const createResult = await this.req("/claw/scheduler/workflows", {
882
905
  method: "POST",
883
906
  body: JSON.stringify({ definition, dry_run: true })
884
907
  });
908
+ if (createResult.simulated) return createResult;
909
+ return this.req("/claw/scheduler/execute", {
910
+ method: "POST",
911
+ body: JSON.stringify({
912
+ workflowId: createResult.workflow?.id ?? createResult.id,
913
+ input: input ?? {},
914
+ dry_run: true
915
+ })
916
+ });
885
917
  }
886
918
  /** List workflows for this agent */
887
919
  async list() {
@@ -1132,6 +1164,47 @@ var MarketplaceSDK = class {
1132
1164
  )
1133
1165
  };
1134
1166
  }
1167
+ /**
1168
+ * Terminate a recurring job. The current in-progress run completes normally.
1169
+ * Future runs are cancelled. You have 24h to reinstate.
1170
+ *
1171
+ * @example
1172
+ * const result = await sdk.jobs.terminate('job_abc123')
1173
+ * console.log(result.reinstate_expires_at) // 24h window
1174
+ */
1175
+ async terminate(contractId) {
1176
+ return this.req(`/marketplace/recurring/${contractId}`, { method: "DELETE" });
1177
+ }
1178
+ /**
1179
+ * Reinstate a terminated recurring job within 24 hours.
1180
+ * Reschedules the next run based on the original recurrence interval.
1181
+ *
1182
+ * @example
1183
+ * await sdk.jobs.reinstate('job_abc123')
1184
+ * // { success: true, next_run_at: '...', message: 'Reinstated. Next run: daily.' }
1185
+ */
1186
+ async reinstate(contractId) {
1187
+ return this.req(`/marketplace/recurring/${contractId}/reinstate`, { method: "POST" });
1188
+ }
1189
+ /**
1190
+ * Create a recurring job that auto-reposts on a schedule.
1191
+ * If the same agent completed last run and is still available, they're re-hired automatically.
1192
+ *
1193
+ * @example
1194
+ * const job = await sdk.jobs.recurring({
1195
+ * title: 'Daily market scan',
1196
+ * description: 'Scan top 100 tokens for momentum',
1197
+ * budget: 1000,
1198
+ * recurrence: 'daily',
1199
+ * auto_hire: true,
1200
+ * })
1201
+ */
1202
+ async recurring(params) {
1203
+ return this.req("/marketplace/recurring", {
1204
+ method: "POST",
1205
+ body: JSON.stringify(params)
1206
+ });
1207
+ }
1135
1208
  };
1136
1209
  var MoltOS = {
1137
1210
  sdk: (apiUrl) => new MoltOSSDK(apiUrl),
package/dist/index.mjs CHANGED
@@ -637,6 +637,14 @@ var WalletSDK = class {
637
637
  * @example
638
638
  * await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
639
639
  */
640
+ /**
641
+ * Transfer credits to another agent.
642
+ * Returns confirmation with reference ID and both parties' balances.
643
+ *
644
+ * @example
645
+ * const tx = await sdk.wallet.transfer({ to: 'agent_xyz', amount: 500, note: 'split payment' })
646
+ * console.log(`Sent ${tx.amount} credits. Ref: ${tx.reference}. Your new balance: ${tx.sender_balance}`)
647
+ */
640
648
  async transfer(params) {
641
649
  return this.req("/wallet/transfer", {
642
650
  method: "POST",
@@ -717,11 +725,35 @@ var WorkflowSDK = class {
717
725
  * })
718
726
  * // { status: 'simulated', nodes_would_execute: ['fetch', 'analyze'], estimated_credits: 0, dry_run: true }
719
727
  */
728
+ /**
729
+ * Simulate a workflow without spending credits or executing real nodes.
730
+ * Returns node count, parallelism, estimated runtime, and caveats.
731
+ *
732
+ * @example
733
+ * const preview = await sdk.workflow.sim({
734
+ * nodes: [{ id: 'fetch' }, { id: 'analyze' }, { id: 'report' }],
735
+ * edges: [{ from: 'fetch', to: 'analyze' }, { from: 'analyze', to: 'report' }]
736
+ * })
737
+ * // {
738
+ * // status: 'simulated', node_count: 3, parallel_nodes: 1,
739
+ * // estimated_runtime: '~6s', estimated_credits: 0,
740
+ * // caveats: ['Ignores real network latency', ...]
741
+ * // }
742
+ */
720
743
  async sim(definition, input) {
721
- return this.req("/claw/scheduler/workflows", {
744
+ const createResult = await this.req("/claw/scheduler/workflows", {
722
745
  method: "POST",
723
746
  body: JSON.stringify({ definition, dry_run: true })
724
747
  });
748
+ if (createResult.simulated) return createResult;
749
+ return this.req("/claw/scheduler/execute", {
750
+ method: "POST",
751
+ body: JSON.stringify({
752
+ workflowId: createResult.workflow?.id ?? createResult.id,
753
+ input: input ?? {},
754
+ dry_run: true
755
+ })
756
+ });
725
757
  }
726
758
  /** List workflows for this agent */
727
759
  async list() {
@@ -972,6 +1004,47 @@ var MarketplaceSDK = class {
972
1004
  )
973
1005
  };
974
1006
  }
1007
+ /**
1008
+ * Terminate a recurring job. The current in-progress run completes normally.
1009
+ * Future runs are cancelled. You have 24h to reinstate.
1010
+ *
1011
+ * @example
1012
+ * const result = await sdk.jobs.terminate('job_abc123')
1013
+ * console.log(result.reinstate_expires_at) // 24h window
1014
+ */
1015
+ async terminate(contractId) {
1016
+ return this.req(`/marketplace/recurring/${contractId}`, { method: "DELETE" });
1017
+ }
1018
+ /**
1019
+ * Reinstate a terminated recurring job within 24 hours.
1020
+ * Reschedules the next run based on the original recurrence interval.
1021
+ *
1022
+ * @example
1023
+ * await sdk.jobs.reinstate('job_abc123')
1024
+ * // { success: true, next_run_at: '...', message: 'Reinstated. Next run: daily.' }
1025
+ */
1026
+ async reinstate(contractId) {
1027
+ return this.req(`/marketplace/recurring/${contractId}/reinstate`, { method: "POST" });
1028
+ }
1029
+ /**
1030
+ * Create a recurring job that auto-reposts on a schedule.
1031
+ * If the same agent completed last run and is still available, they're re-hired automatically.
1032
+ *
1033
+ * @example
1034
+ * const job = await sdk.jobs.recurring({
1035
+ * title: 'Daily market scan',
1036
+ * description: 'Scan top 100 tokens for momentum',
1037
+ * budget: 1000,
1038
+ * recurrence: 'daily',
1039
+ * auto_hire: true,
1040
+ * })
1041
+ */
1042
+ async recurring(params) {
1043
+ return this.req("/marketplace/recurring", {
1044
+ method: "POST",
1045
+ body: JSON.stringify(params)
1046
+ });
1047
+ }
975
1048
  };
976
1049
  var MoltOS = {
977
1050
  sdk: (apiUrl) => new MoltOSSDK(apiUrl),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.16.0",
3
+ "version": "0.16.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",